admin管理员组文章数量:1312888
With tkinter on Python you can use the following trick to raise a window
root.lift()
root.attributes('-topmost',True)
root.after_idle(root.attributes,'-topmost',False)
However, on kde plasma it appears not to work. Instead when you set '-topmost'
to false the window is lowered again.
Here is some code that demonstrates the behaviour.
import tkinter as tk
window = tk.Tk()
ok = tk.Button(window, takefocus=tk.YES, text="raise after delay")
ok.pack()
state = {"mouse_on_button": True}
def handle_enter(_):
state["mouse_on_button"] = True
def handle_leave(_):
state["mouse_on_button"] = False
def handle_click(_):
if state["mouse_on_button"]:
run()
ok.bind("<Enter>", handle_enter)
ok.bind("<Leave>", handle_leave)
ok.bind("<ButtonRelease-1>", handle_click)
def run():
print("Lowering")
window.after(1000, raise_window)
print("Done")
def raise_window():
#window.lift()
window.attributes('-topmost', True)
window.after(500, remove_topmost)
def remove_topmost():
window.attributes('-topmost', False)
window.mainloop()
How do I raise a window with tkinter on kde? One work around is to call wmctrl - which seems to be able to raise windows, but I would prefer the solution to be cross platform?
About my system
plasma version: 5.27.11, kde framework version: 5.115.0, qt: 5.15.13. I'm using X11.
本文标签: pythonRaise a window using tkinter on kdeStack Overflow
版权声明:本文标题:python - Raise a window using tkinter on kde? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741877067a2402526.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论