0
如何在放大應用程序窗口時將樹視圖窗口小部件粘貼到Noth(工具欄)。Tkinter Treeview網格對齊問題
它堅持西南和東,但不是北。
使用:
self.tree.grid(row=1,column=0,sticky=N+W+E+S)
我 這在tree.grid對準配置
...
self.vsb = ttk.Scrollbar(master, orient=VERTICAL, command=self.tree.yview)
self.hsb = ttk.Scrollbar(master, orient=HORIZONTAL, command=self.tree.xview)
self.vsb.grid(row=1, column=1, sticky='ns')
self.hsb.grid(row=2, column=0, sticky='ew')
self.tree.configure(yscrollcommand=self.vsb.set)
self.tree.configure(xscrollcommand=self.hsb.set)
self.tree.grid(row=1,column=0,sticky=N+W+E+S)
...
這是工具欄網格配置(如果它導致問題)
...
self.toolbar = Frame(master, bg="blue")
self.upButton = Button(self.toolbar, text="Up", command=self.doNothing, padx=10, pady=10)
self.upButton.grid(row=0,column=0,sticky=N+W)
self.downButton = Button(self.toolbar, text="Down", command=self.doNothing, padx=10, pady=10)
self.downButton.grid(row=0,column=1, sticky=N+W)
self.insupButton = Button(self.toolbar, text="Insert UP", command=lambda: self.insertUp(self.tree), padx=10, pady=10)
self.insupButton.grid(row=0,column=2, sticky=N+W)
self.insdownButton = Button(self.toolbar, text="Insert Down", command=lambda: self.insertDown(self.tree), padx=10, pady=10)
self.insdownButton.grid(row=0,column=3, sticky=N+W)
self.delbrButton = Button(self.toolbar, text="Delete branch", command=lambda: self.deleteBr(self.tree), padx=10, pady=10)
self.delbrButton.grid(row=0,column=4, sticky=N+W)
self.deltreeButton = Button(self.toolbar, text="Delete entire tree", command=lambda: self.deleteTr(self.tree), padx=10, pady=10)
self.deltreeButton.grid(row=0,column=5, sticky=N+W)
self.searchButton = Button(self.toolbar, text='Search', command=lambda: self.searchTr(self.tree), padx=10, pady=10)
self.searchButton.grid(row=0,column=6, sticky=N+W)
self.calcButton = Button(self.toolbar, text='Calc', command=lambda: self.calcTree(self.tree), padx=10, pady=10)
self.calcButton.grid(row=0,column=7, sticky=N+W)
self.toolbar.grid(row=0,column=0, sticky=N+W)
...
發佈時的應用程序:
觀察結果:應用按比例放大
觀察結果:應用按比例縮小(使用工具欄重疊)
期望的結果:應用擴大
感謝布萊恩的寶貴信息。這解決了這個問題。 – AJN 2015-03-25 02:26:20