0
我剛剛從Python 2.5轉移到2.7,並且我看到我在2.5中創建的GUI在2.7中看起來不同。我在Tkinter中使用「sticky = E + W」命令來擴展某些小部件,以覆蓋我的GUI的全部寬度。在2.5中,這些小部件會自動居中,但在2.7中,這些部件與我的GUI左側對齊。我無法找到解決此問題的命令。任何人都可以幫助我?小部件在python中的對齊方式不同2.7 2.7 python 2.5
這裏是在Python 2.5和2.7我的GUI畫面(對不起,我不得不刪除標籤,因爲它是我對我的工作創造了一個GUI ..)
關於更多的細節代碼我使用:
root = Tk()
root.grid()
F = Frame(root, relief = GROOVE, borderwidth = 3)
F.grid(row = 0, column = 0, sticky = EW)
Label(F,text = 'Data Source:', font = ('Arial',10)).grid(row = 0, column = 0)
LocalVar = IntVar()
CB1 = Radiobutton(F, text = 'Option 1', variable = LocalVar, value = 0, font = ('Arial',10,'italic'))
CB1.grid(row = 0, column = 1)
CB2 = Radiobutton(F, text = 'Option 2', variable = LocalVar, value = 1, font = ('Arial',10,'italic'))
CB2.grid(row = 0, column = 2)
FAQ = Button(root, bitmap = "info", width = 40, command = ShowFAQ, bg = '#0F238C', fg = 'white')
FAQ.grid(row = 0, column = 0, sticky = E)
問候, 里斯
我無法在OS-X上使用python 2.7.3重現。小部件看起來以我爲中心(我假設你在談論標籤)。 - 要清楚的是,你能否發佈一個截圖鏈接(1個顯示2.5個gui,1個顯示2.7個gui)?另外,你在使用什麼操作系統? – mgilson
@mgilson:我已經用圖片更新了我的問題(很遺憾,我無法添加圖片,因爲我剛剛使用了stackoverflow註冊),並且包含了更多我的代碼。此外,我正在使用Win7。 – Yoris
在編輯的代碼中,就像在原始代碼中一樣,您不需要爲列添加任何權重。這至少是問題的一部分。 –