Tkinter部分点击可通过吗? (仅Windows)

我正在编写一个将标尺悬停在所有其他屏幕内容上的应用程序。我使用以下命令使tkinter窗口和关联的画布透明:

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

在使用pyinstaller编译为exe之前,我可以单击透明的该应用程序。但是,编译为exe后,这不再可能。

我尝试了以下共享的解决方案:Tkinter see through window not affected by mouse clicks 但是,这使整个窗口都可以单击,这意味着我不能再与顶部窗口的非透明部分进行交互(必须这样做)。

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 )

我需要能够与根窗口的任何彩色部分移动/交互,但是需要能够单击任何透明部分...到目前为止,我只能完全抓住鼠标或完全错过它

g6228560 回答:Tkinter部分点击可通过吗? (仅Windows)

我也遇到了这个问题...

经过大量尝试,我发现如果将exe文件与也由pyinstaller生成的清单文件一起分发,则点击后功能将按预期工作。

本文链接:https://www.f2er.com/3106388.html

大家都在问