[racket] Does Racket GUI scale?
No, instances of `button%` (or generally `control<%>`) in a scrolling
panel will not scale well. The `racket/gui` library is not designed for
it.
I'm not sure how much the problem is in `racket/gui` versus the
underlying toolkits. Your example program scrolls nicely for me on
Windows and Mac OS X, but not Unix/Gtk, but I would not conclude from that
experiment that the problem is in Gtk. The problem might be the
Gtk-specific part of the implementation of `racket/gui`. Also, I
wouldn't expect any of the platforms to scale to 1000x1000 buttons.
When I tried 100x100 on Mac OS X, it took a couple of seconds to create
all of the buttons.
I think you would have to use `canvas%` and draw/manage the grid and
controls manually. It's possible that the classes of `embedded-gui`
will be useful, if you can set up a suitable harness for snips. (I've
always wanted to make a `table%` class to go along with `text%` and
`pasteboard%`, but I never got around to it.)
At Wed, 9 Jul 2014 12:50:39 +0400, Dmitry Pavlov wrote:
> Hello,
>
> I have to do a simple spreadsheet editor and I wonder
> whether Racket suits my needs. The main challenge
> is that the spreadsheet editor should be able to edit
> tables as big as 1000x1000 or 10000x100 cells.
>
> Here is a stub that I have done, using williams/table-panel
> package from PLaneT: http://pastebin.com/aAjg2TZT
>
> It initializes pretty slow and does the scrolling pretty slow
> even with 20x10 cells, and 100x100 is already almost
> impossible to work with, let alone 1000x1000 or 10000x100.
>
> OK, I thought, maybe I should use the single canvas
> (not separate controls) for the cells, and leave only
> buttons as controls for rows and columns.
>
> But having just 1000 buttons with a scrollbar turned out
> to be slow enough:
>
> #lang racket
> (require racket/gui/base)
>
> (define frame
> (instantiate frame%
> ("Test")))
>
> (define scrolling-panel
> (new vertical-panel%
> (parent frame)
> (style '(auto-vscroll))))
>
> (for ((i (in-range 1000)))
> (new button%
> (parent scrolling-panel)
> (horiz-margin 0)
> (vert-margin 0)
> (label (number->string (+ 1 i)))))
>
> (send frame resize 100 400)
> (send frame show #t)
>
> It takes considerable time to initialize, and the scrolling
> is pretty much of a slide-show kind. Raising the
> number to 10000 makes it a complete no-go.
>
> So I am wondering whether there are hacks to speed
> up the GUI that I am creating.
>
>
> Best regards,
>
> Dmitry
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users