if statement causes tkinter program to hang if statement causes tkinter program to hang tkinter tkinter

if statement causes tkinter program to hang


  • Fixed indentation.
  • Removed Tkinter.Tk()

import Tkinterimport sysimport tkMessageBoxclass GUI(Tkinter.Tk):    """docstring for Values"""    def __init__(self, parent):        Tkinter.Tk.__init__(self,parent)        self.parent = parent        ###if user hits close button        def callback():            if tkMessageBox.askokcancel("Quit", "Do you really wish to quit?"):                self.destroy()                sys.exit()        self.protocol("WM_DELETE_WINDOW", callback)        self.initialize()    def initialize(self):        self.grid()        stepOne = Tkinter.LabelFrame(self, text=" 1. Enter Values ")        stepOne.grid(row=0, columnspan=7, sticky='W',padx=5, pady=5, ipadx=5, ipady=5)        self.Val1Lbl = Tkinter.Label(stepOne,text="Value 1")        self.Val1Lbl.grid(row=0, column=0, sticky='E', padx=5, pady=2)        self.Val1Txt = Tkinter.Entry(stepOne)        self.Val1Txt.grid(row=0, column=1, columnspan=3, pady=2, sticky='WE')        self.Val2Lbl = Tkinter.Label(stepOne,text="Value 2")        self.Val2Lbl.grid(row=1, column=0, sticky='E', padx=5, pady=2)        self.Val2Txt = Tkinter.Entry(stepOne)        self.Val2Txt.grid(row=1, column=1, columnspan=3, pady=2, sticky='WE')        self.val1 = None        self.val2 = None        self.SubmitBtn = Tkinter.Button(stepOne, text="Submit",command=self.submit)        self.SubmitBtn.grid(row=4, column=3, sticky='W', padx=5, pady=2)    def submit(self):        self.val1 = self.Val1Txt.get()        if self.val1 == "":             tkMessageBox.showinfo(message="Value 1 has no values entered")             return        self.val2 = self.Val2Txt.get()        if self.val2 == "":             tkMessageBox.showinfo(message="Value 2 has no values entered")             return        ###Close GUI if Val1 and Val2 have values        if self.val1 and self.val2:             self.destroy()app = GUI(None)app.title('Values')app.mainloop()#calculate values of Val1 and Val2a=float(app.val1)b=float(app.val2)c=a+bprint c