For Programmers: Free Programming Magazines  


Home > Archive > PerlTk > June 2004 > Hidden Canvas Window Objects









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Hidden Canvas Window Objects
Ala Qumsieh

2004-06-15, 3:59 pm

If I create a canvas window object and set its state
to hidden during creation, then the object is not
visible, until I set its state to normal. Good. But,
once the object is visible, I can not configure its
state to hidden again. Actually, Tk doesn't complain
if I do, but the object remains visible.

Here's a simple test script:

#!perl -w

use strict;
use Tk;

my $mw = new MainWindow;
my $c = $mw->Canvas->pack;

my $w = $c->createWindow(50, 50,
-window => $c->Label(-text => 'Hello'),
-state => 'hidden',
);

my $l = $c->createLine(30, 60, 70, 60,
-state => 'hidden',
);

my $i = 0;
$mw->repeat(1000 => sub {
$i++;
$c->itemconfigure($_, -state => $i % 2 ?
'normal' : 'hidden') for $w, $l;
});
MainLoop;
__END__

Same behaviour for Tk800.024 and Tk804.027 under
Linux/Sun/Win32. I'm aware that canvas windows have
some documented limitations like always obscuring
other canvas types, but I'm a bit surprised that
-state => 'hidden' only works at creation time. The
docs don't mention anything about this.

--Ala




__________________________________
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
http://promotions.yahoo.com/new_mail
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
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 majordomo@lists.stanford.edu
Arms, Mike

2004-06-18, 3:57 am

Ala Qumsieh [ala_qumsieh@yahoo.com] wrote:
> If I create a canvas window object and set its state
> to hidden during creation, then the object is not
> visible, until I set its state to normal. Good. But,
> once the object is visible, I can not configure its
> state to hidden again. Actually, Tk doesn't complain
> if I do, but the object remains visible.
>
> Here's a simple test script:
>
> #!perl -w
>
> use strict;
> use Tk;
>
> my $mw = new MainWindow;
> my $c = $mw->Canvas->pack;
>
> my $w = $c->createWindow(50, 50,
> -window => $c->Label(-text => 'Hello'),
> -state => 'hidden',
> );
>
> my $l = $c->createLine(30, 60, 70, 60,
> -state => 'hidden',
> );
>
> my $i = 0;
> $mw->repeat(1000 => sub {
> $i++;
> $c->itemconfigure($_, -state => $i % 2 ?
> 'normal' : 'hidden') for $w, $l;
> });
> MainLoop;
> __END__
>
> Same behaviour for Tk800.024 and Tk804.027 under
> Linux/Sun/Win32. I'm aware that canvas windows have
> some documented limitations like always obscuring
> other canvas types, but I'm a bit surprised that
> -state => 'hidden' only works at creation time. The
> docs don't mention anything about this.


Hi, Ala.

My environment:

ActivePerl 5.6.1 (build 635)
Tk 800.024
Win2K SP3

The behavior I observe is:

1. The main window appears.
2. The text "Hello" appears with a line beneath it
(line is longer than the text).
3. The line disappears for a second and reappears
for a second. Repeat.

The text is not disappearing and reappearing,
only the line. Is this what you are seeing?
I have no idea why the text is not being hidden
like the line.

--
Mike Arms


-++**==--++**==--++**==--++**==--++**==--++**==--++**==
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 majordomo@lists.stanford.edu
Ala Qumsieh

2004-06-18, 3:57 am

--- "Arms, Mike" <marms@sandia.gov> wrote:
> ActivePerl 5.6.1 (build 635)
> Tk 800.024
> Win2K SP3
>
> The behavior I observe is:
>
> 1. The main window appears.
> 2. The text "Hello" appears with a line beneath it
> (line is longer than the text).
> 3. The line disappears for a second and reappears
> for a second. Repeat.
>
> The text is not disappearing and reappearing,
> only the line. Is this what you are seeing?
> I have no idea why the text is not being hidden
> like the line.


Correct. Only the line disappears although the status
of both objects is set to hidden.

--Ala




__________________________________
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
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 majordomo@lists.stanford.edu
Christoph Fuchs

2004-06-18, 8:56 am


>
> Correct. Only the line disappears although the status
> of both objects is set to hidden.
>


I can also reproduce the same behaviour with Tcl/Tk 8.4 (Solaris 8 and 9)

--
+++ Jetzt WLAN-Router für alle DSL-Einsteiger und Wechsler +++
GMX DSL-Powertarife zudem 3 Monate gratis* http://www.gmx.net/dsl

-++**==--++**==--++**==--++**==--++**==--++**==--++**==
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 majordomo@lists.stanford.edu
slaven@rezic.de

2004-06-18, 8:56 am

Ala Qumsieh <ala_qumsieh@yahoo.com> wrote:
> --- "Arms, Mike" <marms@sandia.gov> wrote:
>
> Correct. Only the line disappears although the status
> of both objects is set to hidden.
>
> --Ala
>
>


It seems that hiding widgets is yet unimplemented in the Tk core. Here's
a Tcl/Tk script which shows the same behavior (uh, my Tcl seems to be
quite rusty :-)

pack [canvas .c]
set w [.c create window 50 50 -window [ label .c.label -text Hello ] -state hidden]
set l [.c create line 30 60 70 60 -state hidden]

set i 0

proc repeatproc {} {
global i w l
incr i
if { $i%2 == 0 } {
.c itemconfigure $w -state hidden
.c itemconfigure $l -state hidden
} else {
.c itemconfigure $w -state normal
.c itemconfigure $l -state normal
}
after 1000 repeatproc
}

after 1000 repeatproc

# END

Maybe it's better to remove the widget from the canvas instead:

#!perl -w

use strict;
use Tk;

my $mw = new MainWindow;
my $c = $mw->Canvas->pack;

my $lw = $c->Label(-text => 'Hello');
my $w = $c->createWindow(50, 50,
);

my $l = $c->createLine(30, 60, 70, 60,
-state => 'hidden',
);

my $i = 0;
$mw->repeat(1000 => sub {
$i++;
$c->itemconfigure($l, -state => $i % 2 ? 'normal' : 'hidden');
$c->itemconfigure($w, -window => $i % 2 ? $lw : undef);
});
MainLoop;
__END__

Regards,
Slaven

--
__o Slaven Rezic
_`\<,_ slaven <at> rezic <dot> de
__(_)/ (_)____
________________________________________
______________________________________
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
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 majordomo@lists.stanford.edu
Ala Qumsieh

2004-06-18, 3:58 pm

--- slaven@rezic.de wrote:
> It seems that hiding widgets is yet unimplemented in
> the Tk core. Here's
> a Tcl/Tk script which shows the same behavior (uh,
> my Tcl seems to be
> quite rusty :-)


Thanks for the confirmation. Your Tcl looks good to me
:)

> Maybe it's better to remove the widget from the
> canvas instead:


My workaround is to move the window off screen to some
large negative coordinate.

--Ala


________________________________________
__________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
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 majordomo@lists.stanford.edu
Larry W. Virden

2004-06-29, 4:07 pm


From: slaven@rezic.de
> It seems that hiding widgets is yet unimplemented in the Tk core. Here's
> a Tcl/Tk script which shows the same behavior (uh, my Tcl seems to be
> quite rusty :-)


Has anyone submitted this as a bug report to the tk sf.net project?
--
Tcl - The glue of a new generation. <URL: http://wiki.tcl.tk/ >
Larry W. Virden <mailto:lvirden@cas.org> <URL: http://www.purl.org/NET/lvirden/>
Even if explicitly stated to the contrary, nothing in this posting should
be construed as representing my employer's opinions.
-><-
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
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 majordomo@lists.stanford.edu
Ala Qumsieh

2004-06-29, 4:07 pm

--- "Larry W. Virden" <lvirden@cas.org> wrote:
>
> From: slaven@rezic.de
> in the Tk core. Here's
> my Tcl seems to be
>
> Has anyone submitted this as a bug report to the tk
> sf.net project?


I don't think so. Can you please do it?

Thanks,
--Ala




__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
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 majordomo@lists.stanford.edu
Larry W. Virden

2004-06-29, 8:56 pm


From: Ala Qumsieh <ala_qumsieh@yahoo.com>
> --- "Larry W. Virden" <lvirden@cas.org> wrote:
>
> I don't think so. Can you please do it?


Alas, I don't understand the issues well enough.
--
Tcl - The glue of a new generation. <URL: http://wiki.tcl.tk/ >
Larry W. Virden <mailto:lvirden@cas.org> <URL: http://www.purl.org/NET/lvirden/>
Even if explicitly stated to the contrary, nothing in this posting should
be construed as representing my employer's opinions.
-><-
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
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 majordomo@lists.stanford.edu
Ala Qumsieh

2004-06-29, 8:56 pm

--- "Larry W. Virden" <lvirden@cas.org> wrote:

> Alas, I don't understand the issues well enough.


I just submitted the bug.

--Ala





__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
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 majordomo@lists.stanford.edu
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com