how to create and destroy a top level in tkinter by threading processor

Viewed 37

I am working on a Inventory Software for shop, the exe file is working fine, but its becoming latency for some data extraction, all working on main thread only. so as data increases the process becoming slow, so I am working on threading but some complication are there

some sample code is given below

from tkinter import *

root = Tk()

win_ = None


class Hover(Thread):
    def run(self):
        win_ = Toplevel(root)


class Hi(Thread):
    def run(self):
        win_.destroy()


def entered(e):
    Hover().start()


def leaved(e):
    Hi().start()


but = Button(root, text='Hover', width=8, )
but.pack(pady=20)

but.bind("<Enter>", entered)
but.bind("<Leave>", leaved)

root.mainloop()

I am referred low of working examples all working classes only can we work on methods in class , is that possible

like

class Hover():
    def run(self, Thread):
        win_ = Toplevel(root)

it will be so much thankful if any one worked on this...

0 Answers
Related