我正在尝试用tkinter编写程序.我还没有完成程序,但试图运行它只是为了看看我的窗口看起来如何,我在tkinter中得到一个错误.
我不知道现在该怎么办.谁知道错了什么?
这是消息
Traceback (most recent call last):
File "Box
#---------------------- define GUI class
class CalcMPG:
def __init__(self):
self.main_window = tkinter.Tk()
#-------------- create 3 frames ---------
self.uframe= tkinter.Frame(self.main_window) #upper frame
self.mframe= tkinter.Frame(self.main_window) #middle frame
self.bframe= tkinter.Frame(self.main_window) #button frame
#------------ create the 3 label widgets ------------
self.lblgal= tkinter.Label(self.uframe,text="Enter # of gallons used")
self.lblmiles= tkinter.Label(self.mframe,text="Enter miles travelled")
#------------ create the 2 Entry widgets ------------
self.entgal= tkinter.Entry(self.uframe,width=10)
self.entmiles= tkinter.Entry(self.mframe,width=10)
#------------ create the 2 Button widgets -----------
self.mpgbtn = tkinter.Button(self.bframe,"Calcualte MPG")
self.extbtn = tkinter.Button(self.bframe,"Exit")
#-------- pack upper frame -----------
self.lblgal.pack(side='left')
self.entgal.pack(side='right')
#------- pack middle frame ----------
self.lblmiles.pack(side='left')
self.entmiles.pack(side='right')
#------- pack bottom frome ----------
self.mpgbtn.pack(side= 'left')
self.extbtn.pack(side= 'right')
#------- pack frames --------
self.uframe.pack(side='top')
self.mframe.pack(side='top')
self.bframe.pack(side='top')
tkinter.mainloop()
#--------------- define main function ----
def main():
calcmpg = CalcMPG()
#--------- invoke main function -------
main()
@H_404_13@