Re: Tk::FunkyButton ?
Slaven Rezic <[email protected]>
| Newsgroups | gmane.comp.lang.perl.tk |
|---|---|
| Message-ID | <[email protected]> |
Ala Qumsieh <[email protected]> writes: > --- Dean Arnold <[email protected]> wrote: > > > To do "styled" buttons: > > > > 1. generate button image(s), using either > > static image files, or at runtime using > > <insert favorite graphics package here, e.g., GD> > > > > 2. Create borderless button widgets > > > > 3. Use a -command callback that > > explicitly reads the current mouse position > > and ignores the button press/release events > > unless its over the desired image area > > (or the button has keyboard focus) > > > > 4. (Optional) swap button images on press/release, > > and/or on Motion, FocusIn and FocusOut events, > > for a rollover effect > > > > Is that the gist of your statement ? > > Not really, I'm not THAT smart :) > The problem with image-based buttons, as far as I can > see, is that the size has to be hard-coded. For > example, if the button is packed with '-fill => x' and > the window is resized, then the image needs to > dynamically change to accomodate. > > As for my comment in the previous post, I really meant > that the Canvas is a very heavy object, compared to a > simple Button, and using multiple Canvases to emulate > buttons will incur additional, and perhaps > unnecessary, memory usage. I don't think speed would > be a big issue, but we need to do more tests to > quantify that. > I was curious and did some tests with Tk800.024 (perl5.8.0, FreeBSD, XFree86 4.x) by just creating 1000 buttons resp. canvases and not packing them: perl -MTk -MTk::Canvas -MTk::Button -e 'warn $$; $mw=tkinit;for (1..1000) { $mw->Button };MainLoop' The canvas version consumed 7050K, while the button version consumed 6860K. If removing the loading of the Tk::Canvas module, then numbers are better for the button version. But all in all, not that bad. One would think that the canvas would consume much more memory, if you have in mind how featurerich canvases are. Regards, Slaven -- Slaven Rezic - slaven <at> rezic <dot> de tknotes - A knotes clone, written in Perl/Tk. http://ptktools.sourceforge.net/#tknotes -++**==--++**==--++**==--++**==--++**==--++**==--++**== This message was posted through the Stanford campus mailing list server. If you wish to unsubscribe from this mailing list, send the message body of "unsubscribe ptk" to [email protected]