我希望在窗口最大化时扩展小部件。请查看以下示例代码,如果我们运行此代码,则会获得一些树视图,但如果我们最大化窗口,则树视图将移动到左上角,是否可能在最大化后自动调整大小并完美适配。谢谢。
import os
import tkinter as tk
import tkinter.ttk as ttk
import datetime
import re
import threading
class Window:
i=0
def __init__(self,master):
self.master=master
self.master.geometry('700x350+350+100')
self.label = tk.Label(self.master, text='Sample', font=("Arial", 20)).grid(row=0,columnspan=3)
cols = ('A','B','C')
self.treeview = ttk.Treeview(self.master, columns=cols)
v_scrollbar = ttk.Scrollbar(self.master, orient='vertical', command=self.treeview.yview)
self.treeview.config( yscrollcommand=v_scrollbar.set)
for col in cols:
self.treeview.heading(col, text=col)
self.treeview.column(col,minwidth=0,width=170)
self.treeview.grid(row=1, column=0)
v_scrollbar.grid(row=1, column=1, sticky='nes')
#--- main---
def main():
root = tk.Tk()
Window(root)
root.mainloop()
if __name__ == '__main__':
main()
pack()
? - Delrius Euphoria