【问题标题】:how to use matchbox keyboard using subprocess in raspberry pi?如何在树莓派中使用子进程使用火柴盒键盘?
【发布时间】:2022-12-06 02:06:20
【问题描述】:

我想在附有触摸屏的树莓派上运行我的代码。 GUI 是使用 pyqt5 制作的,我想在输入焦点时弹出系统屏幕键盘。

我不知道,尝试了很多东西但不知道如何使用它。

【问题讨论】:

    标签: subprocess


    【解决方案1】:

    要在带有触摸屏的 Raspberry Pi 上使用屏幕键盘,您可以使用 onboard 包。

    sudo apt-get install onboard

    要使屏幕键盘在 PyQt5 应用程序中的文本输入字段获得焦点时自动弹出,您可以使用 Qt.WA_InputMethodEnabled 属性。可以在小部件上设置此属性以启用该小部件的输入法,例如屏幕键盘。

    以下是如何在 PyQt5 代码中使用此属性的示例:

    from PyQt5 import QtCore
    
    # ...
    
    # Set the WA_InputMethodEnabled attribute on the text entry widget
    text_entry_widget.setAttribute(QtCore.Qt.WA_InputMethodEnabled, True)
    

    您还可以使用 QtGui.QInputMethod 类以编程方式控制屏幕键盘。如果您想根据应用程序中的某些条件显示或隐藏屏幕键盘,这会很有用。

    以下是如何使用 QInputMethod 类显示屏幕键盘的示例:

    from PyQt5 import QtGui
    
    # ...
    
    # Get the input method
    input_method = QtGui.QGuiApplication.inputMethod()
    
    # Show the onscreen keyboard
    input_method.show()
    
    

    【讨论】:

      猜你喜欢
      • 2022-08-10
      • 1970-01-01
      • 2020-01-16
      • 1970-01-01
      • 2020-01-27
      • 2019-06-28
      • 1970-01-01
      • 2021-07-01
      • 1970-01-01
      相关资源
      最近更新 更多