2015-02-23 57 views
0

请看附上的代码。我试图预先显示我的GUI,但没有出现,没有GUI,并且在命令窗口上没有错误。它应该是一个主窗口,然后是两个父框架,以及它们中的子框架。Python Tkinter,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()  
+3

''__init_'!='__init __''... – jonrsharpe 2015-02-23 20:49:58

回答

4

您没有在两侧为两个下划线命名初始化程序。其次,你使用了甚至不存在的函数。例如,

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

我没有在任何地方看到self.load函数。调试是一项重要的技能,您应该花时间学习。

+0

我一定很累。谢谢! haha – entropy4money 2015-02-23 20:53:13

+0

如果可以,请标记为答案。 – 2015-02-23 20:55:06

+0

当然。我知道功能,我注意到,只要我运行我的程序并修复它。我错过了一些东西,但现在它按预期工作:)。我之前做过修补程序的GUI,今天我很累。 – entropy4money 2015-02-23 21:02:49