New to Tkinter GUI building
Adam
adamgarstang at googlemail.com
Thu Mar 1 15:01:40 EST 2007
Ok the window has resized but the elements inside are still like they
were, so they are going off the edge on the window. How can I get
these to resize? I have put sizes on the frames they are in. Sorry to
keep asking but I'm flying blind here, I have checked the python site
and the intro to tkinter which are both usually good for this kinda
thing.
#####CODE#####
#file/path finder
#indentation value 4
import os,glob
import Tkinter as tk
# Class to create the Application and UI
class Theapp:
def __init__(self):
# Create GUI parts. Will allign later with grid
self.top = tk.Tk()
self.top.geometry("%dx%d%+d%+d" % (700, 400, 0, 0)) #
(width,height, x, y)
self.mainWindow = tk.Frame(self.top)#width=700, height=400)
self.labAll = tk.Label(self.mainWindow, text="All Files/
Folders:")
self.labVi = tk.Label(self.mainWindow, text="Violating Files/
Folders:")
#Create a sub-frame containing textbox and scrollbar for All
files scanned display
self.allTxtf = tk.Frame(self.mainWindow, width=690,
height=164)
self.scrlr1 = tk.Scrollbar(self.allTxtf)
self.txtBoxall = tk.Text(self.allTxtf, wrap=tk.CHAR,
yscrollcommand=self.scrlr1.set)
self.scrlr1.config(command = self.txtBoxall.yview)
#Create another sub-frame containing textbox and scrollbar for
the Violating files display
self.viTxtf = tk.Frame(self.mainWindow, width=690, height=164)
self.scrlr2 = tk.Scrollbar(self.viTxtf)
self. txtBoxvi = tk.Text(self.viTxtf, wrap=tk.CHAR,
yscrollcommand=self.scrlr2.set)
self.scrlr2.config(command = self.txtBoxvi.yview)
#Create another sub-frame to contain the controls
self.ctrlFrame = tk.Frame(self.mainWindow, width=690,
height=72)
self.labDir = tk.Label(self.ctrlFrame, text="Dir:")
self.entDir = tk.Entry(self.ctrlFrame)
self.labChar = tk.Label(self.ctrlFrame, text="Char. Limit:")
self.entChar = tk.Entry(self.ctrlFrame, textvariable="254")
self.btFind = tk.Button(self.ctrlFrame, text="Scan", command =
self.fillboxes)
self.btExit = tk.Button(self.ctrlFrame, text="Exit", command =
self.quitEvent)
#Use tkinter's grid geometry manager to allign and display the
GUI
self.mainWindow.grid()
#Frist allign the 3 main frames
self.labAll.grid(row=0)
self.allTxtf.grid(row=1)
self.labVi.grid(row=2)
self.viTxtf.grid(row=3)
self.ctrlFrame.grid(row=4)
#Now allign the content of allTxtf
self.txtBoxall.grid(row=0, column=0)
self.scrlr1.grid(row=0, column=1, sticky=tk.N + tk.S)
#Now allign the content for viTxtf
self.txtBoxvi.grid(row=0, column=0)
self.scrlr2.grid(row=0, column=1, sticky=tk.N + tk.S)
#Now allign the content for ctrlFrame
self.labDir.grid(row=0, column=0, sticky=tk.E)
self.entDir.grid(row=0, column=1)
self.labChar.grid(row=0, column=2, sticky=tk.E)
self.entChar.grid(row=0, column=3)
self.btFind.grid(row=0, column=4)
self.btExit.grid(row=0,column=5)
def findallfiles(self, base):
Pass
def fillboxes(self):
Pass
def quitEvent(self):
raise SystemExit
app = Theapp()
app.mainWindow.mainloop()
#####END#####
Regards,
Adam
More information about the Python-list
mailing list