Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to cater for Windows user text size in PyQt5?
Forum Updated to NodeBB v4.3 + New Features

How to cater for Windows user text size in PyQt5?

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 2 Posters 3.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    Sorry I can't answer that right away but you should give more information about your software stack and OS version so people can try to reproduce your issue.

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
    • D Offline
      D Offline
      donquibeats
      wrote on last edited by
      #3

      Sure, no problem. Python 3.7, Qt / PyQt 5.14.2, Windows 10 version 1909. What other info would be helpful?

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #4

        How you installed it can also be useful (conda VS pip VS ?)

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • D Offline
          D Offline
          donquibeats
          wrote on last edited by
          #5

          I'm working in PyCharm 2019.12, which handles the installation of libraries from requirements.txt using (I think) pip.

          I'm using PyInstaller to create executable files of the application to test on other machines, but get the same results when running directly in the PyCharm virtual environment too.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #6

            Can you check if you have the same issue with PySide2 ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • D Offline
              D Offline
              donquibeats
              wrote on last edited by
              #7

              I can do that, but I've not used PySide2 at all so far so it might take me a little time. I'll get back to you.

              1 Reply Last reply
              0
              • D Offline
                D Offline
                donquibeats
                wrote on last edited by
                #8

                OK, that didn't take anywhere near as long as I expected.

                PySide2 appears to have the same problem- the text of items in the main window doesn't scale for the environment settings. Strangely, in PySide2 the status bar label at the bottom doesn't scale either, while in PyQt5, the status bar label did scale for text size.

                So my question still remains- how am I meant to get my application to scale all the text to suit the user's accessibility settings, instead of just some of it? Are there changes or additions I can make to my code to make this work as expected on Windows, without affecting Mac users etc.?

                The result I got from PySide2 was:

                Test window screengrab with inconsistent font sizes

                The 'correct' expected result would be that all the text would be large, the same size as the "One Two Three" on the menu bar, as this is what the Windows "make text bigger" settings ought to do- but Qt appears to only partially implement this?

                The source code is exactly the same as before, but with the imports changed from PyQt5 to PySide2:

                from PySide2 import QtCore
                from PySide2.QtWidgets import QApplication
                from PySide2.QtWidgets import QGridLayout, QLabel, QMainWindow, QPushButton, QFrame
                import sys
                
                
                class TestDialog(QMainWindow):
                    def __init__(self, parent, windowTitle):
                        super().__init__(parent)
                        self.setWindowTitle(windowTitle)
                        self.setWindowFlags(QtCore.Qt.Window |
                                            QtCore.Qt.WindowTitleHint |
                                            QtCore.Qt.WindowCloseButtonHint |
                                            QtCore.Qt.WindowStaysOnTopHint)
                        self.name = windowTitle
                        self.parent_window = parent
                
                        menu = self.menuBar()
                        menu.addAction("One")
                        menu.addAction("Two")
                        menu.addAction("Three")
                
                        screen = QApplication.screens()[0]
                        dpiScaling = screen.logicalDotsPerInch()
                
                        self.frame = QFrame()
                        self.grid = QGridLayout()
                        self.frame.setLayout(self.grid)
                        self.setCentralWidget(self.frame)
                        self.scalingLabel = QLabel("DPI scaling: " + str(dpiScaling))
                        self.grid.addWidget(self.scalingLabel, 0, 0)
                        self.uselessButton = QPushButton("Button in the main area")
                        self.grid.addWidget(self.uselessButton, 1, 0)
                
                        self.statusBar().addWidget(QLabel("Text on the status bar"))
                
                
                if __name__ == '__main__':
                    app = QApplication(sys.argv)
                    app.setStyleSheet("Fusion")
                    windowTitle = "Scaling test"
                    testDialog = TestDialog(None, windowTitle)
                    testDialog.show()
                    sys.exit(app.exec_())
                
                
                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  donquibeats
                  wrote on last edited by
                  #9

                  Just to add, the above test was on PySide2 5.15.0. I've also just tested it with PyQt5 5.15.0 with the same results.

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    Then I would say you found a bug. You should check the bug report system to see if it's something known. If not please create a new report providing your examples and the results you obtained.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    1
                    • D Offline
                      D Offline
                      donquibeats
                      wrote on last edited by
                      #11

                      Thanks for the response. As you suggested, I have posted this as a potential bug, now visible at https://bugreports.qt.io/browse/QTBUG-85491

                      As far as I'm aware there's nothing that I could add to my code to compensate for this in the meantime? I can't see a Qt method or function that makes the Windows text size setting accessible so that it could be compensated for manually.

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved