473,322 Members | 1,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Tkinter pack bug in Python 2.3


The compact form of pack behaves differently (and I believe incorrectly)
compared to the long form. The following two scripts demonstrate it, at
least on this interpreter:
Python 2.3.2 (#1, Oct 9 2003, 12:03:29)
[GCC 3.3.1 (cygming special)] on cygwin
# First script, no bug

# I want a canvas inside a frame inside a toplevel, with the canvas
# filling the toplevel even as I resize the window. This does it.

from Tkinter import *

root = Tk()
frame = Frame(root, bg="lightBlue")
frame.pack(side=TOP, expand=1, fill=BOTH)
canvas = Canvas(frame, bg="lightGreen")
canvas.pack(side=TOP, expand=1, fill=BOTH)

mainloop()

# Second script, bug

# I want a canvas inside a frame inside a toplevel, with the canvas
# filling the toplevel even as I resize the window. This doesn't do
# it, and instead makes the canvas a sibling of the frame, instead of
# a child. (Try resizing the toplevel and you'll see.) Why?

from Tkinter import *

root = Tk()
frame = Frame(root, bg="lightBlue").pack(side=TOP, expand=1, fill=BOTH)
canvas = Canvas(frame, bg="lightGreen").pack(side=TOP, expand=1, fill=BOTH)

mainloop()

Frank (filologo disneyano) http://www-lce.eng.cam.ac.uk/~fms27/
Jul 18 '05 #1
2 1896
Frank Stajano wrote:

The compact form of pack behaves differently (and I believe incorrectly)
compared to the long form. The following two scripts demonstrate it, at
There is no "compact form", see below.

[...]
# Second script, bug

# I want a canvas inside a frame inside a toplevel, with the canvas
# filling the toplevel even as I resize the window. This doesn't do
# it, and instead makes the canvas a sibling of the frame, instead of
# a child. (Try resizing the toplevel and you'll see.) Why?

from Tkinter import *

root = Tk()
frame = Frame(root, bg="lightBlue").pack(side=TOP, expand=1, fill=BOTH)
You are assigning the result of the pack() method, i. e. None, to frame
here, and consequently Canvas is constructed with None instead of a Frame
instance as the first argument.
canvas = Canvas(frame, bg="lightGreen").pack(side=TOP, expand=1,
fill=BOTH)

mainloop()


Peter
Jul 18 '05 #2

"Frank Stajano" <fm***@cam.ac.uk

Old Perl programmer, hmm... ;-)

Kindly
MichaelP
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: srijit | last post by:
Hello, Any idea - why the following code crashes on my Win 98 machine with Python 2.3? Everytime I run this code, I have to reboot my machine. I also have Win32all-157 installed. from Tkinter...
2
by: Paul A. Wilson | last post by:
I'm new to Tkinter programming and am having trouble creating a reusable button bar... I want to be able to feed my class a dictionary of button names and function names, which the class will make....
6
by: Elaine Jackson | last post by:
I've got a script where a button gets pushed over and over: to cut down on the carpal tunnel syndrome I'd like to have the button respond to presses of the Enter key as well as mouse clicks; can...
2
by: Mark English | last post by:
Is there a safe way to run tkinter in a multithreaded app where the mainloop runs in a background thread ? Here's some test code demonstrating the problem. I'm running Python2.4 under Windows...
5
by: max(01)* | last post by:
hello. i wrote a very simple tkinter demo program that uses menus, buttons, labels, entries, frames and secondary toplevels. it is a python version of a java program made by a colleague. ...
1
by: C D Wood | last post by:
To whom this may concern, Below is the source code, which demonstrates a problem I am having making a GUI for my python project work. 'table.txt' is a file that is read from the same folder....
1
by: Michael Yanowitz | last post by:
Hello: Below I have included a stripped down version of the GUI I am working on. It contains 2 dialog boxes - one main and one settings. It has the following problems, probably all related, that...
5
by: H J van Rooyen | last post by:
Hi, I am struggling to get the pack method to do what I intend. I am trying to display user input in a seperate window, along with a little description of the field, something like this: ...
4
by: MartinRinehart | last post by:
Everything I've read about Tkinter says you create your window and then call its mainloop() method. But that's not really true. This is enough to launch a default window from the console: ...
3
by: J-Burns | last post by:
Hello. Im a bit new to using Tkinter and im not a real pro in programming itself... :P. Need some help here. Problem 1: How do I make something appear on 2 separate windows using Tkinter? By...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.