2012-11-26 123 views
2

我正在使用Python 2.7來顯示2 Checkbuttons。如果我使用justify = LEFT它會顯示錯誤"global name 'LEFT' is not defined"將Tkinter checkbutton文本字符對齊到左側

class simple_ap(Tkinter.Tk): 
    def __init__(self,parent): 
     Tkinter.Tk.__init__(self,parent) 
     self.parent = parent 
     self.initialize() 

    def initialize(self): 


     Checkbutton = Tkinter.Checkbutton(self,text='All_1',width = 50,justify = LEFT) 
     Checkbutton.grid(column = 0, row = 0) 

     Checkbutton = Tkinter.Checkbutton (self,text='To_check_for_the_space_between_brackets',width = 50) 
     Checkbutton.grid(column = 0, row = 8) 

if __name__ == "__main__": 
    app = simple_ap(None) 
    app.title('my_app') 
    app.mainloop() 

這是用「證明」的正確方法? 我工作過http://www.tutorialspoint.com/python/tk_frame.htm

回答

3

看起來好像您使用的是import Tkinter而不是from Tkinter import *,它在您鏈接的示例中使用。您需要使用Tkinter.LEFT

相關問題