[英]How to make the tkinter window responsive with the widgets placed using pack() method in Tkinter Python?
[英]Python tkinter: how to make the widgets in the middle of window?
我是 TK 的新手。 如何制作 window 中間的 scrlledText 和按鈕。
我執行了代碼,得到了如下圖的綠線,但我希望樣式像紅線一樣。
任何想法? 謝謝。
window= Tk()
window.geometry('500x500')
window.resizable(0,0)
window.title("Server")
msgText = scrolledtext.ScrolledText(window, width=50, height=10, font=("宋體", 10),wrap=WORD)
msgText.grid(row=0, column=0,padx = 20,pady = 10)
self.statusText = scrolledtext.ScrolledText(window, width=50, height=10, font=("宋體", 10),wrap=WORD)
statusText.grid(row=1, column=0,padx = 20,pady = 10)
openFileButton = Button(window, width = 15, text="選擇文件", command=self.openFile)
openFileButton.grid(row=2, column=0, sticky=W)
sendButton = Button(window, text='發送文件', width = 15,command=self.sendFile)
sendButton.grid(row=2, column=1, sticky=E)
看來您需要做的就是在將滾動文本小部件添加到顯示時添加columnspan=2
。 但是,由於您沒有提供適當的 [mcve],因此我無法確定。
msgText.grid(row=0, column=0,padx = 20,pady = 10, columnspan=2)
statusText.grid(row=1, column=0,padx = 20,pady = 10, columnspan=2)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.