Python Tkinter,GUI未生成,没有错误显示

时间:2015-02-23 20:47:44

标签: python user-interface tkinter

请参阅随附的代码。我试图预先显示我的GUI,但没有任何内容,没有GUI,并且命令窗口没有错误。它应该是一个主窗口,然后是两个父帧,以及它们中的子帧。

import Tkinter as tkinter


class successGUI:

    def __init_(self):

        #create main window
        self.main_window = tkinter.Tk()

        #create two mainframes
        self.left_frame = tkinter.Frame()
        self.right_frame = tkinter.Frame()

        #create frames to group widgets
        #left frame's
        self.top_lframe = tkinter.Frame(self.left_frame)
        self.lseparator1 = tkinter.Frame(self.left_frame,height=2, bd=1, relief='sunken')
        self.path_frame = tkinter.Frame(self.left_frame)
        self.output_frame = tkinter.Frame(self.left_frame)
        self.lseparator2 = tkinter.Frame(self.left_frame,height=2, bd=1, relief='sunken')
        self.load_frame = tkinter.Frame(self.left_frame)
        self.start_frame = tkinter.Frame(self.left_frame)
        self.lseparator3 = tkinter.Frame(self.left_frame)
        self.status_frame = tkinter.Frame(self.left_frame)
        self.lseparator4 = tkinter.Frame(self.left_frame)

        #right frame's
        self.top_rframe = tkinter.Frame(self.right_frame)

        #create widgets for the top frame
        self.title_label = tkinter.Label(self.top_lframe, text = 'Title??', font = 14)
        self.ghost_label = tkinter.Label(self.top_lframe, width = 50, height = 2)
        #pack the top frame's widget
        self.title_label.pack()
        self.ghost_label.pack()

        #create widgets for the path frame
        self.input_label = tkinter.Label(self.path_frame, \
                                                text = 'File Path:', width = 10)
        self.input_entry = tkinter.Entry(self.path_frame, \
                                                width = 40)

        #pack the path frame's widgets
        self.input_label.pack(side='left')
        self.input_entry.pack(side='left')

        #create widgets for the output frame

        self.output_label = tkinter.Label(self.output_frame, \
                                                text = 'Output Path:',width = 10)
        self.output_entry = tkinter.Entry(self.output_frame, \
                                                width = 40)

        #pack the output frame's widgets
        self.output_label.pack(side='left')
        self.output_entry.pack(side='left')


        #create widgets for load_frame
        self.ghost_label2 = tkinter.Label(self.load_frame, width=10,height=1)
        self.load_button = tkinter.Button(self.load_frame, text = 'Load',
                                          command=self.load)
        self.loadsuccess = tkinter.Label(self.load_frame, 
                                         textvariable = self.load_value)


        #pack the load frame's widgets
        self.ghost_label2.pack()
        self.load_button.pack(side='left')
        self.loadsuccess.pack(side='left')


        #create the widgets for the start frame
        self.start_button = tkinter.Label(self.start_frame, text = 'Start',
                                          command = self.start)
        self.ghost_label3 = tkinter.Label(self.load_frame, width = 10, height=1)

        #pack the start frame's widgets
        self.start_button.pack()
        self.ghost_label3.pack()

        #create the widgets for the status frame
        self.status = tkinter.Label(self.status_frame,text = 'Status:', width = 15)
        self.status_bar = tkinter.Label(self.status_frame, bd=1, 
                                        relief='sunken', anchor='w',width = 5, 
                                        textvariable = self.value)

        #pack the status frame's widgets
        self.status.pack(side = 'left')
        self.status_bar.pack(side='left')

        #pack the parent frames

        self.left_frame.pack(side = 'left',expand=True, fill="both")
        self.right_frame.pack(side = 'left',expand=True, fill="both")

        #pack the children frames
        self.top_rframe.pack()
        self.top_lframe.pack()
        self.lseparator1.pack(fill='x',padx=5,pady=5)
        self.path_frame()
        self.output_frame()
        self.lseparator2(fill='x',padx=5,pady=5)
        self.load_frame()
        self.start_frame()
        self.lseparator3()
        self.status_frame()
        self.lseparator4()



        #self.toprframe.pack()

        tkinter.mainloop()

        def start(self):
            print ('yeap')

succes = successGUI()      

1 个答案:

答案 0 :(得分:4)

你没有用两个下划线命名你的初始化程序。其次,你使用的功能甚至不存在。例如,

self.load_button = tkinter.Button(self.load_frame, text = 'Load',
                                          command=self.load)

我无法在任何地方看到self.load功能。调试是您应该花时间学习的基本技能。