Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

window focus and stacking in TK

by nop (Hermit)
on Nov 07, 2001 at 16:27 UTC ( #123803=perlquestion: print w/replies, xml ) Need Help??
nop has asked for the wisdom of the Perl Monks concerning the following question:

I am learning TK, thanks for your patience with my questions!

When I throw off a new window,
$win->bind('<Return>' => sub { my $win2 = $win->Toplevel; my $image = $win2->Photo; $image->configure(-file=>&nowpic); $win2->Label(-image=>$image)->pack; $win2->title(&nowpic); } );
how do I ensure the focus stays on the primary window ( $win ), and the new window ($win2) shows up below the primary?



Replies are listed 'Best First'.
Re: window focus and stacking in TK
by alien_life_form (Pilgrim) on Nov 07, 2001 at 19:11 UTC

    use $toplevel->raise() or $toplevel->raise($other_toplevel) to influence stacking order.

    Also there is a ->focus method that juust might happen to do what you want.

    You can't have everything: where would you put it?
Re: window focus and stacking in TK
by kevin_i_orourke (Friar) on Nov 07, 2001 at 16:36 UTC

    The window focus is controlled by your window manager and you don't have much control over this from within Tk. It tries to protect you from differences between systems and as a result you lose some functionality.

    You could try playing with withdrawing and deiconifying the windows, if you do this in the right order you might be able to change their relative stacking order.

    Kevin O'Rourke

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://123803]
Approved by root
[jdporter]: I guess that the most direct way of doing it is with some magical incantation involving unpack or whatever
[jdporter]: let me google that for me ;-)
[jdporter]: hex points explicitly to oct, which does the job. :-D
[jdporter]: omg, I f love Perl!
[choroba]: say unpack 'H*', pack 'B*', $mask =~ /0b([01]+)/;
[choroba]: use C instead of H to get the decimal number
[erix]: ( no love like f love )

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2018-02-20 16:34 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (272 votes). Check out past polls.