4

我正在使用 Python 2.7 来显示 2 Checkbuttons。如果我使用justify = LEFT它会显示错误"global name 'LEFT' is not defined"

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

4

1 回答 1

5

看起来好像您正在使用import Tkinter而不是from Tkinter import *,它在您链接的示例中使用。

你需要使用Tkinter.LEFT.

于 2012-11-26T07:13:59.363 回答