PyQt5 QSpinBox - Getting Stretch factor Last Updated : 22 May, 2020 Comments Improve Suggest changes Like Article Like Report In this article we will see how we can set the stretch factor to the text of the spin box, stretching of text means expanding of text without changing their height only increasing their width. We can change the stretch factor with the help of setStretch method. The minimum stretch factor is 1, and the maximum stretch factor is 4000 In order to do this we use stretch method with the QFont object of the spin box. Syntax : font.stretch() Argument : It takes no argument Return : It returns integer Below is the implementation Python3 1== # importing libraries from PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGui from PyQt5.QtGui import * from PyQt5.QtCore import * import sys class Window(QMainWindow): def __init__(self): super().__init__() # setting title self.setWindowTitle("Python ") # setting geometry self.setGeometry(100, 100, 600, 400) # calling method self.UiComponents() # showing all the widgets self.show() # method for widgets def UiComponents(self): # creating spin box self.spin = QSpinBox(self) # setting geometry to spin box self.spin.setGeometry(100, 100, 250, 40) # setting range to the spin box self.spin.setRange(0, 999999) # setting prefix to spin self.spin.setPrefix("PREFIX ") # setting suffix to spin self.spin.setSuffix(" SUFFIX") # getting font of the spin box font = self.spin.font() # setting stretch factor font.setStretch(200) # reassigning this font to the spin box self.spin.setFont(font) # creating a label label = QLabel(self) # setting geometry to the label label.setGeometry(100, 200, 300, 60) # getting stretch factor s_factor = font.stretch() # setting text to the label label.setText("Stretch Factor : " + str(s_factor)) # create pyqt5 app App = QApplication(sys.argv) # create the instance of our Window window = Window() # start the app sys.exit(App.exec()) Output : Comment More infoAdvertise with us Next Article PyQt5 QSpinBox - Getting base size R rakshitarora Follow Improve Article Tags : Python Python-PyQt Python-gui Python PyQt-SpinBox Practice Tags : python Similar Reads PyQt5 QSpinBox - Getting the frame size In this article we will see how we can get the frame size of the spin box. Frame size is the spin box size relative to its parent including any window frame. By default, frame size of the spin box contains a value that depends on the user's platform and screen geometry. In order to do this we use fr 2 min read PyQt5 QSpinBox - Setting Stretch factor In this article we will see how we can set the stretch factor to the text of the spin box, stretching text means expanding text without changing their height only increasing their width. The minimum stretch factor is 1, and the maximum stretch factor is 4000. Below is how stretched spin box text loo 2 min read PyQt5 QSpinBox - Getting base size In this article we will see how we can set the base size to the spin box, base size is used to calculate a proper spin box size if the spin box defines sizeIncrement. By default, for a newly-created spin box, this property contains a size with zero width and height.In order to set base size we use s 2 min read PyQt5 QSpinBox - Getting the size of the font In this article we will see how we can get size of the spin box's font i.e text. In order to get the size object we have to get the QFontMetrics object of the size box to get the size. The size will be in pixels. In order to do this we use size method with the spin box's QFontMetrics object. Syntax 2 min read PyQt5 QSpinBox - Getting the frame geometry In this article we will see how we can get the frame geometry of the spin box. Frame geometry is the spin box geometry relative to its parent including any window frame. By default, frame geometry of the spin box contains a value that depends on the user's platform and screen geometry. In order to d 2 min read PyQt5 QSpinBox - Getting ascent of the font In this article we will see how we can get the ascent of the spin box's font i.e text. The ascent of a font is the distance from the baseline to the highest position characters extend to. In practice, some font designers break this rule, e.g. when they put more than one accent on top of a character, 2 min read Like