如果我使用pynput global hotkeys,kivy应用程序无法正常工作
我正在尝试创建一个默认情况下隐藏的应用程序,按下组合键时会显示窗口。
我的代码:
from kivy.app import App
from kivy.uix.label import Label
from pynput import keyboard
class MyApp(App):
def open_window(self):
print(f"Key pressed...")
self.root_window.show()
def build(self):
return Label(text="Hello")
def on_start(self):
self.root_window.hide()
with keyboard.GlobalHotKeys({"<ctrl>+<alt>+h": self.open_window}) as h:
h.join()
if __name__ == "__main__":
MyApp().run()
当我运行应用程序时,一切看起来都很好,但没有显示标签,并且我无法通过单击关闭按钮来关闭应用程序。多次尝试关闭窗口后,我收到 python 未响应错误。
谢谢。
I am trying to create an application which is hidden by default and windows is shows when key combination is pressed.
My code:
from kivy.app import App
from kivy.uix.label import Label
from pynput import keyboard
class MyApp(App):
def open_window(self):
print(f"Key pressed...")
self.root_window.show()
def build(self):
return Label(text="Hello")
def on_start(self):
self.root_window.hide()
with keyboard.GlobalHotKeys({"<ctrl>+<alt>+h": self.open_window}) as h:
h.join()
if __name__ == "__main__":
MyApp().run()
When I run the app everything looks fine but no label is shown and I am unable to close the app in single click of close button. After multiple attempts of closing the window I get python not responding error.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用这个
或
use this
or