Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

hide/show widget

635 views
Skip to first unread message

ppp

unread,
Jun 30, 2004, 2:59:58 PM6/30/04
to
is there someway to hide and then show a widget on command, i know it
exists in gtk. i have been doing pack/unpack or grid/ungrid, but its such
a pain, cos when u ungrid it, it loses its place. i want the space to be
empty (or atleast look empty) when i want to hide the widget, and later
make it appear.

Marc Dashevsky

unread,
Jun 30, 2004, 4:29:58 PM6/30/04
to
In article <f310300fdfaf1ef0...@localhost.talkaboutprogramming.com>,
pavi...@hotmail.com says...

The "losing place" issue can be easily resolved by packing
the widget in a frame that remains packed, e.g.:

use strict;
use Tk;

my $onoff = 1;

my $mw = tkinit;
$mw->Label(-text => 'blah')->pack;
my $f = $mw->Frame->pack;
my $l = $f->Label(-text => 'blah2')->pack;
$mw->Label(-text => 'blah3')->pack;
$mw->Button(
-text => 'Toggle',
-command => [\&Toggle, $l],
)->pack;
MainLoop;

sub Toggle {
my($w) = @_;
if ($onoff) {
$w->packForget;
} else {
$w->pack;
}
$onoff = ! $onoff;
}

--
Go to http://MarcDashevsky.com to send me e-mail.

Dieter D'Hoker

unread,
Jul 1, 2004, 11:27:49 AM7/1/04
to

I agree, it would be very handy if their was a $widget->configure(-state =>
'hidden');
But that state is only allowed with items on a canvas ...


--
Dieter D'Hoker
news:free.nl.dieter.dhoker & news:alt.nl.fan.dieter.dhoker
Google? http://neverseenbefore.com/
Multiplayer tetris? http://www.tsrv.com/


0 new messages