Tôi đang cố gắng viết một ui đơn giản với Tkinter trong python và tôi không thể tải các tiện ích trong lưới để thay đổi kích thước. Bất cứ khi nào tôi thay đổi kích thước cửa sổ chính các mục nhập và các tiện ích nút không điều chỉnh chút nào.Lưới Tk sẽ không thay đổi kích thước đúng cách
Đây là mã của tôi:
class Application(Frame):
def __init__(self, master=None):
Frame.__init__(self, master, padding=(3,3,12,12))
self.grid(sticky=N+W+E+S)
self.createWidgets()
def createWidgets(self):
self.dataFileName = StringVar()
self.fileEntry = Entry(self, textvariable=self.dataFileName)
self.fileEntry.grid(row=0, column=0, columnspan=3, sticky=N+S+E+W)
self.loadFileButton = Button(self, text="Load Data", command=self.loadDataClicked)
self.loadFileButton.grid(row=0, column=3, sticky=N+S+E+W)
self.columnconfigure(0, weight=1)
self.columnconfigure(1, weight=1)
self.columnconfigure(2, weight=1)
app = Application()
app.master.title("Sample Application")
app.mainloop()
đã thêm hàng cấu hình để cho phép mở rộng theo chiều dọc –