Reputation: 97
I'm new to python and TKinter. I'm trying to write a program with a basic gui. I wanted basic control over the layout and tried to implement grid. For some reason when I run the code using grid, no window comes up, if I comment that line out, it works fine, but things aren't where I want them. Could anyone give me a clue as to what I'm doing wrong, and more importantly what I'm not understanding?
from Tkinter import *
class Application(Frame):
def createWidgets(self):
self.Name_label = Label(text="Name")
self.Name_label.pack({"side": "left"})
self.Name_label.grid(row=2, column=1)#If I comment this line out, it works.
self.Name = Entry(self)
self.Name.pack({"side": "right"})
#self.Name.grid(column=1, row=0)
self.QUIT = Button(self)
self.QUIT["text"] = "QUIT"
self.QUIT["fg"] = "red"
self.QUIT["command"] = self.quit
self.QUIT.pack(side="bottom")
def __init__(self, master=None):
Frame.__init__(self, master)
self.pack()
self.createWidgets()
root = Tk()
app = Application(master = root)
app.mainloop()
root.destroy()
Upvotes: 1
Views: 88
Reputation: 778
You cannot use both pack and grid. Also you should add your items to your grid
Upvotes: 1