I am developing an application where I have to detect an widget, get its coordinates and draw a rectangle around it. When user click on widget next screen will come and I have to repeat whole process. I have coordinates, and able to draw rectangle using Tkinter but the issue is that my code is being stuck in root.mainloop(). The code for creating tkinter transparent window:
class Application:
def __init__(self,master, coordinates):
self.master = master
self.coordinates= coordinates
self.master.overrideredirect(True)
self.master.wm_attributes("-topmost", True)
self.master.wm_attributes("-disabled", True)
self.master.wm_attributes("-transparentcolor", "white")
self.create_widgets()
def create_widgets(self):
w= Canvas(self.master , bg = "white", bd=0, highlightthickness=0)
w.create_rectangle(self.coordinates[0],self.coordinates[1],100,100)
w.pack()
In main() of another file I am calling
root = tk.Tk()
//coordinates is global list in which coordinates of widget is being set
app = Application(root,coordinates)
//in case if user change screen size, to updates the rectangle coordinates
root.after(1000, do_bold1)
root.mainloop()
//this function is detecting if screen has changed, if changed tkinter window will be hidden, then detecting coordinates again it will be displayed.
is_change= detect_screen()
From threading examples, I got root.mainloop() runs on main thread but how can I run these processes in parallel?