Using virtual keyboard with python3 and Qt5

2k Views Asked by At

I'd like to use Qt's virtual keyboard (Qt5.11.1 or newer?) in my python3 (3.6) project on Win10, but I'm stuck. I have anaconda environment and I'm quite sure the Virtual keyboard is also somewhere in there, because I can find some folders with correct name.

What should the main program look like, besides the obvious, to virtual keyboard pop up when an input widget gets selected?

import sys
from qtpy.QtWidgets import QApplication, QDialog, QVBoxLayout, QSpinBox


class Test(QDialog):

    def __init__(self):
        super(Test, self).__init__()

        layout = QVBoxLayout()
        self.setLayout(layout)

        for i in range(2):
            layout.addWidget(QSpinBox())


if __name__ == '__main__':
    import os

    os.environ["QT_IM_MODULE"] = "qtvirtualkeyboard"
    app = QApplication(sys.argv)
    dialog = Test()
    sys.exit(dialog.exec())

edit: to be clear, i don't want to reinvent or customize the wheel, just use it.

0

There are 0 best solutions below