newbie question about python and Tkinter

N

newbie

Hello,

I am a newbie and have a few questions about Python and Tkinter.

I would like to create the following layout in Python:

*******************************************
* *
* *
* *
* frame 1 *
* *
* *
* *
* *
*******************************************
* * *
* * *
* * *
* frame 3 * frame 2 *
* * *
* * *
* * *
*******************************************

I try to accomplish this with the following code:

from Tkinter import *

root = Tk()
root.title("Critter World")

MyFrame0 = Frame(root, background="brown") # One Parent Frame to rule
them all

MyFrame1 = Frame(MyFrame0, background = "yellow")
MyFrame2 = Frame(MyFrame0, background = "red")
MyFrame3 = Frame(MyFrame0, background = "green")

b1 = Label(MyFrame1, text="World", background="yellow").pack(fill=BOTH,
expand=YES)
b2 = Label(MyFrame2, text="Info", background="red").pack(fill=BOTH,
expand=YES)
b3 = Label(MyFrame3, text="Control",
background="green").pack(fill=BOTH, expand=YES)

MyFrame1.pack(side=TOP, fill=BOTH, expand=YES)
MyFrame2.pack(side=RIGHT, fill=BOTH, expand=YES)
MyFrame3.pack(side=LEFT, fill=BOTH, expand=YES)

MyFrame0.pack(fill=BOTH, expand=YES)
raw_input()
print "\n"*23

When the window resizes, it is only Frame1 that is resized.




However, if I run the following:



from Tkinter import *

root = Tk()
root.title("Critter World")

MyFrame0 = Frame(root, background="brown") # One Parent Frame to rule
them all

MyFrame1 = Frame(MyFrame0, background="yellow")
MyFrame2 = Frame(MyFrame0, background = "red")
MyFrame3 = Frame(MyFrame0, background = "green")
MyFrame4 = Frame(MyFrame0, background = "black")


b1 = Label(MyFrame1, text="World", background="yellow").pack(fill=BOTH,
expand=YES)
b2 = Label(MyFrame2, text="Info", background="red").pack(fill=BOTH,
expand=YES)
b3 = Label(MyFrame3, text="Control",
background="green").pack(fill=BOTH, expand=YES)
b4 = Label(MyFrame3, text="NEXT 1", background="green").pack(fill=BOTH,
expand=YES)


MyFrame1.pack(side=TOP, fill=BOTH, expand=YES)
MyFrame2.pack(side=RIGHT, fill=BOTH, expand=YES)
MyFrame3.pack(side=LEFT, fill=BOTH, expand=YES)
MyFrame4.pack(side=BOTTOM, fill=BOTH, expand=YES)

MyFrame0.pack(fill=BOTH, expand=YES)
raw_input()
print "\n"*23

I get:

*******************************************
* *
* *
* *
* frame 1 *
* *
* *
* *
* *
* *
* *
* *
* *
* *
*******************************************
* * *
* * *
* frame 3 * *
* * *
* * *
************************* frame 2 *
* * *
* * *
* frame 4 * *
* * *
* * *
*******************************************

and when I resize, all frames are resized?

Any idea why?


A related question:

Why does frame 4 not span the bottom ?

i.e.

*******************************************
* *
* *
* *
* frame 1 *
* *
* *
* *
* *
* *
* *
* *
* *
* *
*******************************************
* * *
* * *
* frame 2 * frame 3 *
* * *
* * *
*******************************************
* *
* *
* frame 4 *
* *
* *
*******************************************


NOTE:

I am running PYTHON and Tkinter on a windows' XP box.
 
J

James Stroud

newbie wrote:
[about some tkinter problems]

I'm running:

Python 2.3.4 (#4, Oct 25 2004, 21:40:10)
[GCC 3.3.2 (Mandrake Linux 10.0 3.3.2-6mdk)] on linux2

With tcl/tk 8.3 and your first sample works as expected.
I am running PYTHON and Tkinter on a windows' XP box.

This is probably your problem. Seems like you might have a bug. Is this cygwin?
If not try it.

James
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top