in reply to Re: Perl/Tk Scrolled issue
in thread Perl/Tk Scrolled issue
Artem.use base qw/Tk::Derived Tk::TextUndo/; Construct Tk::Widget 'SearchEntry'; sub ClassInit { my($class, $mw) = @_; $class->SUPER::ClassInit($mw); $mw->bind($class, '<Control-a>', 'selectAll'); $mw->bind($class, '<Key-Tab>', sub { $_[0]->focusNext; Tk->break; +}); } sub Populate { my($self, $args) = @_; $self->menu(undef); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Perl/Tk Scrolled issue
by rcseege (Pilgrim) on Aug 20, 2006 at 19:38 UTC | |
I can't reproduce the problem with the colors, but I can for height/width. It isn't so much a problem as a misunderstanding of the Scrolled composite. When you use it you are delegating responsibility for displaying the 'scrolled' subwidget to the Scrolled composite. Scrolled allows you to initialize the settings (height/width) of the enclosed subwidget up until all events have been processed by MainLoop the first time. So the following will work:Updated: caught and corrected a typo in the first example. Added the qw to the configure method params. But the next, will not:
This is because by the time the Button has been pressed, sizing control has been yielded to Scrolled. You can take it back using the packPropagate method. Notice how the first Change button makes the change, but then when the second Change button tries, it cannot. The size is being passed, it's just not having any visible effect.
Another way I have dealt with this in the past is to enclose the Scrolled widget within another Frame, but set it up to expand/shrink as the parent frame resizes. Then I size the Frame instead of the Scrolled widget. HTH, Rob | [reply] [d/l] [select] |
by artemave (Beadle) on Aug 21, 2006 at 20:33 UTC | |
That really helped. As well as your explanation gave me some understanding of why it works this way. Misunderstanding of Scrolled is partly caused by the lack of documentation. I didn't find anything on this niether in Perl/Tk pod nor in Mastering Perl/Tk. I'd appreciate if you point me some usefull sources of Perl/Tk wisdom. Artem. | [reply] |
by rcseege (Pilgrim) on Aug 22, 2006 at 13:42 UTC | |
Misunderstanding of Scrolled is partly caused by the lack of documentation. Yeah - I completely understand. One of the problems with Perl/Tk IMO, is that it includes so much, it's tough to stay on top of it all and keep up with the Documentation, Patches to minor widgets, etc. The effort isn't all that distributed for such a large distro. I didn't find anything on this niether in Perl/Tk pod nor in Mastering Perl/Tk. I'd appreciate if you point me some usefull sources of Perl/Tk wisdom. There are quite a few resources out there for Perl/Tk. Admittedly, a few of them are showing their age a bit... There is a core set of resources that I go back to time and time again, and you might have found the answer in the first resource. I completely agree that it would have been nice if this "gotcha" had been pointed out in the docs, but what can you do? I hope the abbreviated list below helps. These represent the resources that come to mind the quickest, and I know I've left out many others. There are several books that have coverage of Perl/Tk (which you can find in the FAQ, along with other resources, provided the links are still valid). In addition, I end up turning to Tcl/Tk sites, X Windows references for information on Events, MSDN and other Win32 sites for Windows specific information. This should be a pretty decent sampling. Rob | [reply] |