import tkinter as tkroot = tk.Tk()root.state('zoomed')text1 = tk.Text(state=tk.DISABLED)scroll = tk.Scrollbar(root, command=text1.yview)text1.configure(yscrollcommand=scroll.set)text1.grid(row=1, column=1, sticky='we')scroll.grid(row=1, column=2, sticky="nse")root.mainloop()如何使文本框填充 X 軸?(sticky='we'對我不起作用)
1 回答

翻過高山走不出你
TA貢獻1875條經(jīng)驗 獲得超3個贊
import tkinter as tk
root = tk.Tk()
root.state('zoomed')
text1 = tk.Text(state=tk.DISABLED)
scroll = tk.Scrollbar(root, command=text1.yview)
text1.configure(yscrollcommand=scroll.set)
text1.grid(row=1, column=0,sticky='we')
scroll.grid(row=1, column=1, sticky="ns")
root.grid_columnconfigure(0, weight=1)
root.grid_columnconfigure(1, weight=0)
root.mainloop()
我已經(jīng)將參數(shù) weight 添加到該grid中的列,這基本上是列之間的關系。請看, “重量”在 tkinter 中有什么作用?以獲得更詳細的答案。
添加回答
舉報
0/150
提交
取消