python - How to make click-through windows PyQt -
i make window in pyqt can click through; ie click on window , click passed through can interact whatever behind it, while window remains on top. example of effect trying achieve notifications on ubuntu appear in top-right hand corner default, can click through.
i able in pyqt ideally; if not, platform linux windows solutions welcome!
cheers in advance! i've been giving bit of thought , research, great able this.
edit: trying make window can use tracing paper window behind
here solution on windows using pyqt4.
you need override eventfilter in front widget (on windows winevent) , forward events window.
i'm not sure, there must similar approach can used on other platforms (instead of winevent, maybe x11event?)
good luck!
from pyqt4 import qtcore, qtgui import win32api, win32con, win32gui, win32ui class front(qtgui.qpushbutton): def __init__(self,text="",whndl=none): super(front,self).__init__(text) self.pycwnd = win32ui.createwindowfromhandle(whndl) # install event filter windows' messages. forward messages # other hwnd def winevent(self,msg): # forward left button down message other window. not sure # want exactly, i'm showing left button click. if msg.message == win32con.wm_lbuttondown or \ msg.message == win32con.wm_lbuttonup: print "left click in front window" self.pycwnd.sendmessage(msg.message, msg.wparam, msg.lparam) return true, 0 # tells qt ignore message return super(front,self).winevent(msg) class back(qtgui.qpushbutton): def __init__(self,text=""): super(back,self).__init__(text) self.clicked.connect(self.onclick) def onclick(self): print 'back has been clicked' def main(): = qtgui.qapplication([]) = back("i'm in back...") back.setwindowtitle("i'm in back...") back.show() # hwnd of window in (you need use exact title of window) whndl = win32gui.findwindowex(0, 0, none, "i'm in back...") # i'm making front button bigger obvious in front ... front = front(text="*____________________________*",whndl=whndl) front.setwindowopacity(0.8) front.show() a.exec_() if __name__ == "__main__": main()
Comments
Post a Comment