Hi guys,
I'm new to the list; actually just found out it existed. I'm fairly new
to python and programming, and I'm just beginning with Tkinter. I'm
trying to layout my page, and I'm having problems understanding the
action of some of the frames. I actually posted about this on a general
python help message board and someone suggested that I repost it to
this list. My question is somewhat complex, so in attempt to simplify
things a bit I am posting part of a response I posted in a thread on
the previous message board. Hopefully this fully describes my problem:
When I specify dimensions of the text boxes, no matter how high or low,
the enclosing frame seems to adjust to fit the new boxes. So, for
instance, if I try inserting a text widget in leftframe with dimensions
1x1, leftframe shrinks down to 1x1. If I make the text widget 100x100,
leftframe takes that size. What I want, and what seems like should be
happening, is if I have leftframe which is 500X500 pixels, and I create
a text box wit effective dimensions of 200X200 (I understand that text
widgets use lines as dimensions), the text box should take up a little
less than half of leftframe, with leftframe remaining 500X500 pixels.
Instead, leftframe is shrinking down to become 200X200, and I can't
figure out why. After a while I tried removing the text boxes and I got
the same problem. I think maybe this code will better illustrate the
problem. This first set of code is the totally stripped down version,
and you can see leftframe in white on the left, and rightframe in blue
on the right.
from Tkinter import *
import tkFileDialog,tkSimpleDialog,tkMessageBox
WINDOWWIDTH=500
WINDOWHEIGHT=500
TITLEFONT = ("Courier",12,"normal")
HEADINGFONT = ("Helvetica",9,"bold")
class App:
def __init__ (self,master):
self.window = Frame(master,width=WINDOWWIDTH,height=WINDOWHEIGHT)
self.window.pack(expand=YES, fill=BOTH)
self.master= master
self.currentfeeds = []
#Create frame to contain all others
self.display=Frame(self.window,width=WINDOWWIDTH,height=WINDOWHEIGHT,
bg='black')
self.display.pack()
#Create widgets
self.createwidgets()
def createwidgets(self):
# create a top menu
self.addMenu(self.master)
self.addToolbar()
self.leftframe=Frame(self.display,
width=WINDOWWIDTH/3,height=WINDOWHEIGHT, bg='white')
self.rightframe=Frame(self.display,
width=2*WINDOWWIDTH/3,height=WINDOWHEIGHT, bg='blue')
self.leftframe.pack(side="left", expand="yes", fill="x")
self.rightframe.pack(side="left", expand="yes", fill="x")
def addMenu(self,master):
self.menu = Menu(self.window)
master.config(menu=self.menu)
self.filemenu = Menu(self.menu)
def addToolbar(self):
self.toolbar = Frame(self.display)
self.toolbar.pack(side='top',expand="yes", fill="x")
root=Tk()
app=App(root)
root.mainloop()
Next, if I try to pack ANYTHING inside rightframe, it shrinks down to
size and totally distorts my screen dimensions. Here is the exact same
code, adding a label widget in self.rightframe. It completely shrinks
rightframe and distorts the screen dimensions. Does my question make
sense now?
from Tkinter import *
import tkFileDialog,tkSimpleDialog,tkMessageBox
WINDOWWIDTH=500
WINDOWHEIGHT=500
TITLEFONT = ("Courier",12,"normal")
HEADINGFONT = ("Helvetica",9,"bold")
class App:
def __init__ (self,master):
self.window = Frame(master,width=WINDOWWIDTH,height=WINDOWHEIGHT)
self.window.pack(expand=YES, fill=BOTH)
self.master= master
self.currentfeeds = []
#Create frame to contain all others
self.display=Frame(self.window,width=WINDOWWIDTH,height=WINDOWHEIGHT,
bg='black')
self.display.pack()
#Create widgets
self.createwidgets()
def createwidgets(self):
# create a top menu
self.addMenu(self.master)
self.addToolbar()
self.leftframe=Frame(self.display,
width=WINDOWWIDTH/3,height=WINDOWHEIGHT, bg='white')
self.rightframe=Frame(self.display,
width=2*WINDOWWIDTH/3,height=WINDOWHEIGHT, bg='blue')
self.leftframe.pack(side="left", expand="yes", fill="x")
self.rightframe.pack(side="left", expand="yes", fill="x")
self.label=Label(self.rightframe,text='Current
story',font=HEADINGFONT).pack(side='top')
def addMenu(self,master):
self.menu = Menu(self.window)
master.config(menu=self.menu)
self.filemenu = Menu(self.menu)
def addToolbar(self):
self.toolbar = Frame(self.display)
self.toolbar.pack(side='top',expand="yes", fill="x")
root=Tk()
app=App(root)
root.mainloop()
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss