Grygonos has asked for the wisdom of the Perl Monks concerning the following question:
I have a problem that is driving me insane. I have a Tk::Listbox that I'm passing around to different routines. These routines call
This works. It reconfigures the height and width properly. I can configure it pack it, packForget it, reconfigure it and repack it, and it works when calling it inside the same sub.$widget->configure(-height=>X, -width=>Y);
(i.e. I thought it might be once its packed once those options can't be changed). After each subroutine uses the list I call this routine.#Create a scrolled listbox $list->configure(-height=>12, -width =>12); #Populate the scrolled listbox with tape numbers $list->insert('end',$_) for @tapes; $list->pack(); + $list->packForget(); $list->configure(-height=>12, -width =>100); $list->pack();
So that the next sub that uses it must configure it the way it likes or be stuck with default values. When my next sub gets the reference passed to it like so,sub initList { my $list = shift; #Remove the list from the packing order $list->packForget(); #Remove all elements from the list $list->delete('end') for(0..$list->size); print $list->cget('height'); #Reset heigth and width $list->configure(-height=>1, -width =>1); #Unbind the double click binding $list->bind('<Double-1>',''); return; }
The size of the listbox is not 12 and 12 (although cget'ing the widget says its 12) The size displayed on screen is still the 20x30 that was configured in the subroutine before hand.sub listData { my ($client,$dbh,$dlg,$list) = @_; #retrieve a list of tapeID numbers for a client my @tapes = getTapes($client,$dbh); #Create a DialogBox $dlg->configure(-title=>"Tapes for ".$$client); $dlg->Subwidget('B_1')->configure(-text=>'OK'); $dlg->Subwidget('B_0')->packForget(); #Create a scrolled listbox $list->configure(-height=>12, -width =>12); #Populate the scrolled listbox with tape numbers $list->insert('end',$_) for @tapes; $list->pack(); + #Show the dialog $dlg->Show(); initDialog($dlg); initList($list); return; }
Conversely, if I call this routine first and set it to 12 and 12, the routine that attempts to configure the listbox at 20x30 still shows it at 12x12, and cget'ing those options says 20 and 30
What is going on Monks? Any help?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tk configure problem
by graff (Chancellor) on Jul 15, 2004 at 01:21 UTC | |
by Grygonos (Chaplain) on Jul 15, 2004 at 02:23 UTC | |
by graff (Chancellor) on Jul 15, 2004 at 02:57 UTC | |
by Grygonos (Chaplain) on Jul 15, 2004 at 13:09 UTC | |
|
Re: Tk configure problem
by eserte (Deacon) on Jul 15, 2004 at 09:35 UTC |