Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

pack and grid

by PeterPeiGuo (Hermit)
on Feb 13, 2011 at 06:01 UTC ( [id://887823]=perlquestion: print w/replies, xml ) Need Help??

PeterPeiGuo has asked for the wisdom of the Perl Monks concerning the following question:

I accidentally mixed pack and grid in one Tk program, and the program just hung, and even the main window didn't show. Following is a simplified version to show this:

use warnings; use strict; use Tk; my $mw = new MainWindow(); $mw->Button()->grid($mw->Button()); $mw->Button()->pack(); MainLoop;

However that is not always the case, for example the following version, although it does not neccessarily do what one wants, it at least does not hang:

use warnings; use strict; use Tk; my $mw = new MainWindow(); $mw->Button()->grid(); $mw->Button()->pack(); MainLoop;

Just curious, does anybody know a way, to force Tk at least show an error or warning in similar situations, to ease the debug? Thanks.

Peter (Guo) Pei

Replies are listed 'Best First'.
Re: pack and grid
by vkon (Curate) on Feb 13, 2011 at 09:27 UTC
    your code effectively translates to following Tcl/Tk code:

    this one loops:

    grid [button .b1] [button .b2] pack [button .b3]
    this one shows 2 buttons in a grid:
    grid [button .b1] [button .b2] #pack [button .b3]
    Run it with 'wish' command (provided you have Tcl/Tk installed)

    This is known limitation, and maybe it has some explanation
    I can only say that sometimes you can mix different geometry methods within one parent, sometimes you don't, but generally you shouldn't

    you could discuss this with tcl/tk people, so they will give you more details on the matter if you really interesting

    Remember that you still can use different geometries within different parents - i.e. create a Frame, 'grid' it, and then do 'pack' inside it at your will

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://887823]
Approved by broomduster
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-04-19 13:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found