I am writing an application that hovers a ruler over all other on-screen content. I have made the tkinter window and associated canvas transparent using:
root.overrideredirect(True) #This hides the window outline/controls
root.state('zoomed') #This scales the window to fill the page
root.configure(background=bgColor) #Set bg color of window (used to make transparent \/)
root.wm_attributes("-transparentcolor", bgColor) #Necessary for transparent, window
root.lift()#Lifting window above all others
root.wm_attributes("-topmost", True)#Hold window on top of all other windows
I am able to click through this application where transparent before compiling with pyinstaller to an exe. However after compiling to an exe this is no longer possible.
I attempted the solution shared here: Tkinter see through window not affected by mouse clicks However this makes the entire window click through-able, meaning that I can no longer interact with the non-transparent portions of the top window (which I have to be able to do).
hwnd = win32gui.FindWindow(None, "Digital Ruler") # Getting window handle
# hwnd = root.winfo_id() getting hwnd with Tkinter windows
# hwnd = root.GetHandle() getting hwnd with wx windows
lExStyle = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)
lExStyle |= win32con.WS_EX_TRANSPARENT | win32con.WS_EX_LAYERED
win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE , lExStyle )
I need to be able to move/interact with any colored sections of the root window but need to be able to click through any transparent sections... So far I have only been able to completely seize the mouse or completely miss it.