Home > Archive > PerlTk > March 2005 > Why are my Top Levels greyed out?
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 |
Why are my Top Levels greyed out?
|
|
| Graham 2005-03-06, 3:57 pm |
| I am OK in Perl by a Perl/Tk newbie. One of my first Perl/Tk applications
starts with a Main Window which is then withdrawn and a Top Level is
created, packed with widgets, then destroyed, then a new Top Level created
and the process repeated. Everything works fine except the Top Level windows
are always greyed out and do not colour up until clicked on. I am running Tk
v800.024 on W32. I'm sure the answer must be very simple - please help!
| |
| Graham 2005-03-06, 3:57 pm |
| PS - I'm running Perl 5.6.1
"Graham" <graham@letsgouk.com> wrote in message news:422afde7.0@entanet...
>I am OK in Perl by a Perl/Tk newbie. One of my first Perl/Tk applications
>starts with a Main Window which is then withdrawn and a Top Level is
>created, packed with widgets, then destroyed, then a new Top Level created
>and the process repeated. Everything works fine except the Top Level
>windows are always greyed out and do not colour up until clicked on. I am
>running Tk v800.024 on W32. I'm sure the answer must be very simple -
>please help!
>
| |
| Marc Dashevsky 2005-03-06, 3:57 pm |
| In article <422afde7.0@entanet>, graham@letsgouk.com says...
> I am OK in Perl by a Perl/Tk newbie. One of my first Perl/Tk applications
> starts with a Main Window which is then withdrawn and a Top Level is
> created, packed with widgets, then destroyed, then a new Top Level created
> and the process repeated. Everything works fine except the Top Level windows
> are always greyed out and do not colour up until clicked on. I am running Tk
> v800.024 on W32. I'm sure the answer must be very simple - please help!
I wrote this script that does *not* show the symptom you describe:
use strict;
use Tk;
my $mw = tkinit;
$mw->withdraw;
my $tl = $mw->Toplevel;
$tl->Label(-text => 'Text')->pack;
$tl->Entry->pack;
MainLoop;
Why don't you show us a small working script that demonstrates it?
--
Go to http://MarcDashevsky.com to send me e-mail.
| |
| Graham 2005-03-06, 3:57 pm |
| Hmmmm. Yes, this does work, but I've still got problems. Here is a slimmed
down version of my problem script...
#!/usr/local/bin/perl -w
use strict;
use Tk;
LABEL_1: {};
my $mw = tkinit;
$mw->title("Main Window");
$mw->withdraw();
my $path = $mw->getOpenFile(-title => "Select File");
my $tl = $mw->Toplevel();
$tl->title("Toplevel");
if ($path ne "") {
$tl->Button(-text => "[Exit]", -command => \&callback1)->pack(-side =>
'bottom', -fill => 'x');
$tl->Label(-text => "Why is this greyed out?")->pack();
}
else {
## error stuff
$tl->bell; # why doesn't my computer beep?
$tl->Button(-text => "[Try Again]", -command => \&callback2)->pack(-side =>
'bottom', -fill => 'x');
$tl->Label(-text => "Why is this greyed out too?")->pack();
$tl->Label(-text => "You must select a File")->pack();
}
sub callback1 {
$mw->destroy();
}
sub callback2 {
$mw->destroy();
goto LABEL_1;
}
MainLoop;
print STDOUT "Other side of Mainloop - ready to continue...\n";
print STDOUT "Path = $path\n";
..com to send me e-mail.
| |
| Rob Seegel 2005-03-06, 3:57 pm |
| Aside from some minor nitpicks with the code, this works as expected
for me, your text does not appear "greyed out", and I do hear the bell.
I'm also using the Tk804.027 on a Win32 system.
Rob
Graham wrote:
> Hmmmm. Yes, this does work, but I've still got problems. Here is a slimmed
> down version of my problem script...
>
> #!/usr/local/bin/perl -w
> use strict;
> use Tk;
> LABEL_1: {};
> my $mw = tkinit;
> $mw->title("Main Window");
> $mw->withdraw();
> my $path = $mw->getOpenFile(-title => "Select File");
> my $tl = $mw->Toplevel();
> $tl->title("Toplevel");
> if ($path ne "") {
> $tl->Button(-text => "[Exit]", -command => \&callback1)->pack(-side =>
> 'bottom', -fill => 'x');
> $tl->Label(-text => "Why is this greyed out?")->pack();
> }
>
> else {
> ## error stuff
> $tl->bell; # why doesn't my computer beep?
> $tl->Button(-text => "[Try Again]", -command => \&callback2)->pack(-side =>
> 'bottom', -fill => 'x');
> $tl->Label(-text => "Why is this greyed out too?")->pack();
> $tl->Label(-text => "You must select a File")->pack();
> }
>
> sub callback1 {
> $mw->destroy();
> }
>
> sub callback2 {
> $mw->destroy();
> goto LABEL_1;
> }
>
> MainLoop;
>
> print STDOUT "Other side of Mainloop - ready to continue...\n";
> print STDOUT "Path = $path\n";
> .com to send me e-mail.
>
>
| |
| Marc Dashevsky 2005-03-06, 3:57 pm |
| In article <422b2bac.0@entanet>, graham@letsgouk.com says...
> Hmmmm. Yes, this does work, but I've still got problems. Here is a slimmed
> down version of my problem script...
Grey is the default background color of Tk::Toplevel.
Try:
bg => 'red'
for more excitement. Perhaps though, using gotos is
excitement enough.
> #!/usr/local/bin/perl -w
> use strict;
> use Tk;
> LABEL_1: {};
> my $mw = tkinit;
> $mw->title("Main Window");
> $mw->withdraw();
> my $path = $mw->getOpenFile(-title => "Select File");
> my $tl = $mw->Toplevel();
> $tl->title("Toplevel");
> if ($path ne "") {
> $tl->Button(-text => "[Exit]", -command => \&callback1)->pack(-side =>
> 'bottom', -fill => 'x');
> $tl->Label(-text => "Why is this greyed out?")->pack();
> }
>
> else {
> ## error stuff
> $tl->bell; # why doesn't my computer beep?
> $tl->Button(-text => "[Try Again]", -command => \&callback2)->pack(-side =>
> 'bottom', -fill => 'x');
> $tl->Label(-text => "Why is this greyed out too?")->pack();
> $tl->Label(-text => "You must select a File")->pack();
> }
>
> sub callback1 {
> $mw->destroy();
> }
>
> sub callback2 {
> $mw->destroy();
> goto LABEL_1;
> }
>
> MainLoop;
>
> print STDOUT "Other side of Mainloop - ready to continue...\n";
> print STDOUT "Path = $path\n";
> .com to send me e-mail.
>
>
>
--
Go to http://MarcDashevsky.com to send me e-mail.
| |
| Graham 2005-03-06, 3:57 pm |
| It's not the text that greyed out for me, it's the Toplevel window bar
decoration - normally standard Microsoft blue fading from left to right the
way I have Windows XP set up. Dunno why you hear the bell and I don't.
"Rob Seegel" <RobSeegel@comcast.net> wrote in message
news:heydnYu_MMvH37bfRVn-tg@comcast.com...[color=darkred]
> Aside from some minor nitpicks with the code, this works as expected
> for me, your text does not appear "greyed out", and I do hear the bell.
> I'm also using the Tk804.027 on a Win32 system.
>
> Rob
>
> Graham wrote:
| |
| Graham 2005-03-06, 3:57 pm |
| Funny, cos I ran your program Marc
use strict;
use Tk;
my $mw = tkinit;
$mw->withdraw;
my $tl = $mw->Toplevel;
$tl->Label(-text => 'Text')->pack;
$tl->Entry->pack;
MainLoop;
and eveything was fine and the Toplevel window decoration was not greyed
out. That suggests to me that there is no default background color to
Tk::Toplevel and that Toplevel wigets should take on the decoration applied
by the OS windows manager.
"Marc Dashevsky" <usenet@MarcDashevsky.com> wrote in message
news:MPG.1c950f9211fb522c9896fa@news.comcast.giganews.com...
> In article <422b2bac.0@entanet>, graham@letsgouk.com says...
>
> Grey is the default background color of Tk::Toplevel.
> Try:
> bg => 'red'
>
> for more excitement. Perhaps though, using gotos is
> excitement enough.
>
>
> --
> Go to http://MarcDashevsky.com to send me e-mail.
| |
| Marc Dashevsky 2005-03-07, 4:03 pm |
| In article <422b513f.0@entanet>, graham@letsgouk.com says...
> Funny, cos I ran your program Marc
>
> use strict;
> use Tk;
> my $mw = tkinit;
> $mw->withdraw;
> my $tl = $mw->Toplevel;
> $tl->Label(-text => 'Text')->pack;
> $tl->Entry->pack;
> MainLoop;
>
> and eveything was fine and the Toplevel window decoration was not greyed
> out. That suggests to me that there is no default background color to
> Tk::Toplevel and that Toplevel wigets should take on the decoration applied
> by the OS windows manager.
Well, I learned in your reply to Rob that I was talking about the
body of the Toplevel and you were talking about the window
decoration. Sorry for not reading more carefully. Regardless,
it looks like you have an idiosyncratic interaction between
your installation of perl/Tk and your installation of WinXP.
Maybe it needs to run on 60 cycle current? Heh heh.
--
Go to http://MarcDashevsky.com to send me e-mail.
| |
| Rob Seegel 2005-03-07, 4:03 pm |
| Ohhhh! I think I understand now. When you say "greyed out" you don't
mean literally. You mean that the toplevel doesn't have focus, which can
be important for the keyboard-triggered events.
Try adding this line at the end of each of your subroutines:
$tl->focusForce;
Is this what you were talking about it?
Rob
Graham wrote:
> It's not the text that greyed out for me, it's the Toplevel window bar
> decoration - normally standard Microsoft blue fading from left to right the
> way I have Windows XP set up. Dunno why you hear the bell and I don't.
>
> "Rob Seegel" <RobSeegel@comcast.net> wrote in message
> news:heydnYu_MMvH37bfRVn-tg@comcast.com...
>
>
>
>
| |
| Rob Seegel 2005-03-07, 4:03 pm |
| Or better yet, assign the Button to a variable, and assign the focus
to the Button, since that is likely what the user would be interacting
with. That way the user only needs to hit the Return key to invoke the
Button.
Rob
[color=darkred]
>
> $tl->focusForce;
>
> Is this what you were talking about it?
>
> Rob
>
> Graham wrote:
>
| |
| Rob Seegel 2005-03-07, 4:03 pm |
| BTW, I believe that's a side-effect of getOpenFile.
Rob
| |
| Graham 2005-03-07, 8:58 pm |
| Yippee! Thanks Rob.
Apologies for using incorrect terminology. I thought 'Focus' meant focusing
the cursor into particular wigets (told u I was a Tk newbie!) In fact the
subroutines were the wrong place to insert this line because they destroy
the Main Window - the line needed to be inserted prior to this. Yes, as you
said in your later post, it seems that removal of focus is a side effect of
the 'getOpenFile' method .
Apart from the bell (which doesn't toll for me), all's well now.
"Rob Seegel" <RobSeegel@comcast.net> wrote in message
news:4rmdneQdS7JN77bfRVn-3w@comcast.com...[color=darkred]
> Ohhhh! I think I understand now. When you say "greyed out" you don't mean
> literally. You mean that the toplevel doesn't have focus, which can be
> important for the keyboard-triggered events.
>
> Try adding this line at the end of each of your subroutines:
>
> $tl->focusForce;
>
> Is this what you were talking about it?
>
> Rob
>
> Graham wrote:
>
| |
| Rob Seegel 2005-03-07, 8:58 pm |
| Graham wrote:
> Yippee! Thanks Rob.
> Apologies for using incorrect terminology. I thought 'Focus' meant focusing
> the cursor into particular wigets (told u I was a Tk newbie!) In fact the
> subroutines were the wrong place to insert this line because they destroy
> the Main Window - the line needed to be inserted prior to this. Yes, as you
> said in your later post, it seems that removal of focus is a side effect of
> the 'getOpenFile' method .
>
Oh, right - whoops, I meant at the end of the if/else blocks.
Rob
| |
| Ala Qumsieh 2005-03-07, 8:58 pm |
| Graham wrote:
> Apart from the bell (which doesn't toll for me), all's well now.
I had this before, and found out that the wire that connects my
motherboard to my PC speaker wasn't connected. Perhaps your situation is
similar.
Also, regarding your code. I advise against using goto() in the way you
use it. It is just a nightmare to maintain. Perhaps you can encapsulate
the code that creates the toplevel in a subroutine, and call that
subroutine instead of using goto(). Just my 2 cents.
--Ala
| |
| Graham 2005-03-07, 8:58 pm |
| Xref: number1.nntp.dca.giganews.com comp.lang.perl.tk:43375
Funny, in 8 years of Perling, this is the very first time I've used a goto
{}. You're right - I must be slipping....
"Ala Qumsieh" <notvalid@email.com> wrote in message
news:dK4Xd.4946$C47.460@newssvr14.news.prodigy.com...
> Also, regarding your code. I advise against using goto() in the way you
> use it. It is just a nightmare to maintain. Perhaps you can encapsulate
> the code that creates the toplevel in a subroutine, and call that
> subroutine instead of using goto(). Just my 2 cents.
>
> --Ala
|
|
|
|
|