GUI代码未按预期产生窗口

时间:2019-05-30 01:43:31

标签: python python-3.x

我正在使用breezypythongui,并且已编写此代码来匹配示例文件,但无法获取它以在屏幕上生成窗口。找到here

的指向breezypythongui.py的链接
from breezypythongui import EasyFrame


class ButtonDemo(EasyFrame):
    def __init__(self):
        EasyFrame.__init__(self, title = "Button Demo")

        self.label = self.addLabel(text = "hello world!", row = 0, column = 0, columnspan = 2, sticky = "NSEW")
        self.clearBtn = self.addButton(text = "Clear", row = 1, column = 0, command = self.clear)
        self.restoreBtn = self.addButton(text = "Restore", row = 1, column = 1, command = self.restore, state = "disabled")

    def clear(self):
        self.label["text"] = ""
        self.clearBtn["state"] = "disabled"
        self.restoreBtn["state"] = "normal"

    def restore(self):
        self.label["text"] = "Hello world!"
        self.clearBtn["state"] = "normal"
        self.restoreBtn["state"] = "disabled"

def main():
    ButtonDemo().mainloop()

if __name__ == "  main  ":
    main()

没有回溯或错误代码

1 个答案:

答案 0 :(得分:0)

在代码“ main”中缺少下划线,因此我的更正代码是:

if __name__ == "  main  ":
    main()


if __name__ == "__main__":
    main()