Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Transfer the size of the font in the operating system to the Python Qt program



  • Hi,

    in the Windows operating system, people with a visual impairment can increase the font of the operating system to 125% in "Settings" → "Ease of use" → "Display" in "Increase text". My Python Qt program does not make this change.

    Annotation:
    With Java Swing it can be achieved by implementing a certain Java code. With JavaFX the transfer works without extra Java code.

    Question:
    What do I have to do for such a change to be applied to my Python Qt program?



  • My solution:

    def applicationtypesetting(appv, fontsize):
        font = appv.font()
        font.setPointSize(font.pointSize() * fontsize)
        appv.setFont(font)
    
    def main():
        app = QtWidgets.QApplication([])
        win = MainWindow()
        if len(sys.argv) >= 2:
            applicationtypesetting(app, int(sys.argv[1]))
        else:
            applicationtypesetting(app, 1);
        win.showNormal()
        app.exec_()
    

    If someone has a visual impairment they can call the program as follows:
    python.exe PQTTexteditor.py 2

    Question: Do the Python professionals have a better idea?


Log in to reply