python - 将 Tkinter 复选按钮文本字符向左对齐

标签 python python-2.7 tkinter

我正在使用 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()

这是使用“justify”的正确方法吗? 我工作了 http://www.tutorialspoint.com/python/tk_frame.htm

最佳答案

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

你需要使用Tkinter.LEFT

关于python - 将 Tkinter 复选按钮文本字符向左对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13560081/

相关文章:

python - 在 Tkinter 中更改多个窗口的背景

python - 带和不带关键字参数的 Lambda 函数行为

python - 如何检查字符串是否包含 Python 列表中的元素

mongodb - mongoDB 中的高插入时间

python - 如何在python中将原始图像转换为png?

python-2.7 - 在 PySpark 中比较地理空间数据的最有效方法

python - tkinter root.mainloop 与 While True 循环

python - 使用来自另一个 Python 进程的数据更新小部件,而不阻塞它

python - Windows 中 .dll 文件的含义是什么......? Linux 中 .so 文件的含义是什么?

python - 具有 3 列的 DataFrame 到字典的字典