Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 基本Tkinter帧应用程序不工作_Python_User Interface_Tkinter_Widget - Fatal编程技术网

Python 基本Tkinter帧应用程序不工作

Python 基本Tkinter帧应用程序不工作,python,user-interface,tkinter,widget,Python,User Interface,Tkinter,Widget,我正在尝试使用Python学习Tkinter,但我无法让这个基本应用程序正常工作: from tkinter import Tk, Frame, BOTH class Example(Frame): def __init__(self, parent): Frame.__init__(self, parent, background="white") self.parent = parent self.initUI() def

我正在尝试使用Python学习Tkinter,但我无法让这个基本应用程序正常工作:

from tkinter import Tk, Frame, BOTH

class Example(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent, background="white")
        self.parent = parent

        self.initUI()

    def initUI():
        self.parent.title("A simple app")
        self.pack(fill=BOTH, expand=1)

def main():
    root = Tk()
    root.geometry("250x150+300+300")
    app = Example(root)
    root.mainloop()

if __name__ == '__main__':
    main() 
代码可以运行,但我想只有根容器的标题是“tk”

谢谢你的帮助


附言:我使用的是带IDLE的Python 3.4。

这段代码运行时没有错误?是的,但我自己发现了错误,谢谢。问题是我的initUI()func在它的定义中没有自参数。一个mod可以按回答勾选我的问题吗?谢谢。回答下面的问题并将其标记为答案!