-1
我不能在Mac上使用Tkinter for Python 3中的grid
函數。每當我嘗試運行它,IDLE停止響應,我必須退出它,但是當我使用.pack()
函數時,它運行良好。爲什麼我不能使用網格功能?
from tkinter import *
class MainWindow:
def __init__(self):
window = Tk()
frame = Frame(window, width=600, height=800)
frame.pack(expand=True)
btframe = Frame(window)
btframe.pack(side=BOTTOM, expand=True)
self.intro = Label(frame, text="Welcome to your personal email client", font =("Courier", 20, "bold"))
self.name = Label(frame, text="\nName",foreground="red", font=("Helvetica",16,"bold"))
self.password = Label(frame, text="\nPassword", foreground="blue", font=("Helvetica",16,"bold"))
self.entry1 = Entry(frame)
self.entry2 = Entry(frame)
self.intro.pack()
self.name.grid(row=1, column=2)
self.entry1.grid(row=1, column=3)
self.password.grid(row=3, column=2)
self.entry2.grid(row=3, column=3)
self.submitB = Button(btframe, text="Submit", command= self.display)
self.quitB = Button(btframe, text="Quit", command=window.destroy)
self.submitB.pack()
self.quitB.pack()
window.mainloop()
def display(self):
print("Submitted Succesfully")
MainWindow()
你是混合在同一容器中'grid'和'pack' - 這是一個非常糟糕的主意。 – jonrsharpe