in reply to Tk configure problem
I was intrigued by the idea of a GUI design where the geometry of certain widgets will change as a result of user (or data) activity at run-time. (Normally, it's not the sort of approach I would recommend -- consistent size and placement of widgets throughout the run-time of the GUI will tend to be an aid to consistent and correct usage. But I can imagine cases where changing the size of a widget dynamically could be useful.)
Anyway, just I wanted to see if I could change the size of a listbox easily, and it seems this is doable:
#!/usr/bin/perl use strict; use Tk; my $mw = MainWindow->new; my $btnframe = $mw->Frame()->pack(-side => 'top'); my $lstframe = $mw->Frame()->pack(-side => 'top'); my $listbox = $lstframe->Listbox(-height => 16, -width => 16)->pack; my @listdata = <DATA>; chomp @listdata; $listbox->insert( 'end', @listdata ); for (qw/5x8 10x10 16x20/) { $btnframe->Button(-text => $_, -command => [ \&resize, $listbox, $_ ], )->pack(-side => 'left'); } MainLoop; sub resize { my ( $lbox, $size ) = @_; my ( $newh, $neww ) = split( /x/, $size ); $lbox->packForget; $lbox->configure(-height => $newh, -width => $neww ); $lbox->pack; } __DATA__ 1234567890123456 ABCDEFGHIJK 1234567890 abcdefghi 12345 stuv foo bar baz junk extra lines last line with no blank following
That's just a simple proof-of-concept, to show that a callback routine (such as would be invoked by a Button widget) can reconfigure the dimensions of a listbox widget.
So the question would be: what is in your code (or missing from your code) that makes it different from this simple example?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Tk configure problem
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 |