Tk locks up - 100% c.p.u. on a simple program (Tcl, Perl, Python)
Archive - Originally posted on "The Horse's Mouth" - 2007-09-09 07:13:50 - Graham EllisFighting packs and grids - Tk under Tcl, Perl, Python
You'll use pack OR grid to place components into your frame in a Tcl/Tk application. You may use both pack and grid within the same program, but NOT within the same frame. If you do, not only will you be writing code that has no clear meaning, but you'll also invoke the pack and grid handlers at the same time and may cause them to fight. Have a look at this code:
button .ouch -text "do NOT press this button" -command exit
label .more -text "This is a label"
button .wow -text "This is a button you may press" -command exit
label .contd -text "Another BORING! label"
grid .more .ouch
pack .ouch .more
pack .contd .wow
grid .wow .contd
When I ran that, my prompt was lost, no wish window appeared, and my c.p.u. utilisation rocketed to 99% ... and stayed there. I guess when you have two individuals fighting, they don't show any regard at all for others around them.
Footnote I've often contended that the way to get a user to select a button is to label it "Do not push this under any circumstances" ... which is what I have put in the example above. Some may say that I have a warped sense of humour, or that I have watched too much "Trigger Happy TV".