我目前鑽研比「以往」前進入Tkinter的GUI深,我已經找到了.grid()
幾何管理是不夠的幾個原因:
這些情節是基於其中最大的小部件 - 這種相對性導致不準確。
在Windows 7上的Python 2.7.3,該計劃似乎並沒有聽從我的行號,而是喜歡使用小工具的順序。
我的代碼
我目前工作的一個真的基本的文本編輯器,我想對框架的頂部多個按鈕。我一直無法這樣做,因爲我的部件放在要麼是占主導地位的屏幕中心的大規模文本框的最左邊或右邊。
========Class __init__ Stuff============
def widget(self):#Place widgets here
#Save Button
self.saveButton = Button (self, text = "Save", command = self.saveMe)
self.saveButton.grid(column = 0, row = 0, sticky = W)
#Open Button
self.openButton = Button (self, text = "Open", command = self.openMe)
self.openButton.grid(column = 0, row = 1, sticky = W)
#Area where you write
self.text = Text (self, width = (root.winfo_screenwidth() - 20),
height = (root.winfo_screenheight() - 10))
self.text.grid(row = 2)
==============Mainloop/Command Stuff============
我的問題
是否有另一種方式來使用.grid()
幾何管理的方式,更準確的,或者我應該完全使用其他功能?
謝謝!
你對windows的評論不是「heeding your row numbers」是不正確的。幾十年來,網格幾何管理器已被證明在所有平臺上都可以100%運行。我並不是說你的代碼不是行爲不端,這只是因爲你認爲它的原因而不是行爲不端。 – 2013-02-13 12:07:35