0

I am using Tkinker for creating a progress bar in my Django project. Firstly I try to use Celery but I cannot do it so I looked for other alternatives and I found that. I implement Tkinker to my project and it works but after the window opens and the code is running but the window stops working. say not response. Like that:

Not response

How can I work this? And this is my code:

class myFunction():

    def __init__(self, user, password, url, port, db_password, username):

        self.zaman = datetime.now().strftime("%Y-%m-%d")
        ...
        self.download_all(user, password, url, port, db_password)
        ...
    def download_all(self, user, password, url, port, db_password):
        # creating tkinter window
        root = Tk()
        # Progress bar widget
        progress = Progressbar(root, orient=HORIZONTAL,
                               length=100, mode='determinate')

        root.title("Sending")
        root.attributes("-topmost", True)
        w = root.winfo_reqwidth()
        h = root.winfo_reqheight()
        ws = root.winfo_screenwidth()
        hs = root.winfo_screenheight()
        x = (ws / 2) - (w / 2)
        y = (hs / 2) - (h / 2)
        root.geometry('+%d+%d' % (x, y))

       
        try:
            sys.path.append('../')
            ...

                bar = Bar('Processing', max=len(scans))
                # try download and save scans into each folder the belong to
                pb_length = len(scans)
                print("------pb length-----------")
                print(pb_length)
                pb_value = 100/pb_length
                print("------pb val-----------")
                print(pb_value)

                for s in scans:
                    progress['value'] = pb_value
                    root.update_idletasks()
                    bar.next()
                    scanner.scan_name = s['name']
                    scanner.scan_id = s['id']
                    ...
                    
                progress.pack(pady=10)
                bar.finish()


            else:
                ...
        except KeyError and ConnectionError:
            pass
edche
  • 636
  • 6
  • 33
  • Does this answer your question? [How do you run your own code alongside Tkinter's event loop?](https://stackoverflow.com/questions/459083/how-do-you-run-your-own-code-alongside-tkinters-event-loop) – Matiiss Oct 31 '21 at 17:37
  • @Matiiss I saw this but I cannot use it. I am very confused. – edche Oct 31 '21 at 17:44

0 Answers0