just started tkinter , posting snippet of code. label
, button
label
, button
class objects respectively.
when button pressed first time on_button_click_organisation
called changes button
configuration , when click on_button_click_compute
called, expected perform time taking action via main
method.
but gui gets stuck until main() ends. how stop , make button active once excecution returns after computing main() , inactive till then?
def on_button_click_organisation(self): self.organisation_file = askopenfilename(filetypes=[("*.csv", "csv")]) print("organisation file : " + self.organisation_file) self.label.config(text = "start code") self.button.config(text = "start", command = self.on_button_click_compute) def on_button_click_compute(self): self.label.config(text = "wait..\nresult being computed\n(might take 15 minutes)") self.button.config(state = disabled) #time taking task main(self.filename, self.organisation_file, self.result_folder) sleep(5) #to mimic time taking main() if main() returns in less time self.button.config(state = normal) self.label.config(text = "done..\ncheck result folder") self.button.configure(text = "finish", command=root.quit())
Comments
Post a Comment