python - tkinter -button doesn't display the label until whole function(associated with button) is processed -
i creating gui using tkinter
in python 2.7
. in gui there buttons perform functions. issue when button clicked, doesn't display label until whole function finished. sample code:
button4=tk.button(self,text="memory",height=1,width=20,font=label_font,fg=mycolor,bg='light blue',command=lambda: controller.show_frame(memory)) button4.place(relx=0.6, rely=.53,width=120, anchor="sw")
the funtion associated button is:
def memory(self): label = tk.label( self, text="calculating, please wait...", font=text_font, fg="white", bg=mycolor) label.place(relx=.0005, rely=.17) f3 = open('filename' ,"r") list1= list() list2= list() # calculating values takes around 5 minutes lists huge
here text "please wait..." displayed after 5 minutes, i.e. after calculation. need text (label) displayed after button clicked.
thanks help.
call update before starting long calculations
def memory(self): label = tk.label( self, text="calculating, please wait...", font=text_font, fg="white", bg=mycolor) label.place(relx=.0005, rely=.17) self.update() f3 = open('filename' ,"r") list1= list() list2= list() # calculating values takes around 5 minutes lists huge
but you'd better use thread
Comments
Post a Comment