2

I want to get a loading dialog box while I call a API call in my tkinter application i have implement a custom Dialog box in it but the dialog box is not cumming basically the whole application freezes and dialog box also does not come. this is a sample function which run when i click on submit button and then this function runs the api call and and open the dialog box while api is making call and also changes frame/navigate to other frame.

        def login_button_fuction():

            top = tk.Toplevel(self)
            top.title("loading")
            top.geometry("200x100")
            top.resizable(0, 0)
            bar = ttk.Progressbar(top, orient="horizontal",
                                  length=100, mode="indeterminate")
            bar.pack(pady=25)
            bar.start()
            url = "XXXXXXXXXXXXXXXXXXX"
            payload = json.dumps(
                {"username": username_entry.get(), "password": password_entry.get()})
            headers = {'Content-Type': 'application/json'}
            response = requests.post(url+"/users/getuser", data=payload, headers=headers)

            if response.json()["resultCode"] == 100:
                print("success")
                data = {
                    "realname": response.json()["data"]["realname"],
                    "phone": response.json()["data"]["phone"]}
                with open("user_data.dat", "wb") as f:
                    pickle.dump(data, f)
                controller.show_frame(dashboardPage.dashboard_page)

            else:
                print("error")
            bar.grid_forget()
            top.destroy()

Also if any one can tell me how can i remove the minimize and close buttons from tkinter Dialog Box it will be very helpful Thanks! this Question is not already answered i have searched and tried to find it but not getting any appropriate answer.

lexi
  • 57
  • 5

0 Answers0