Open In App

PyQt5 QSpinBox – Getting Vertical Logical DPI value

Last Updated : 28 May, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

In this article we will see how we can get the vertical resolution of the device in dots per inch(DPI) of the spin box. Logical dots per inch are used to convert font and user interface elements from point sizes to pixel sizes, and might be different from the physical dots per inch.

Note : If the vertical logical DPI doesn’t equal to the physical vertical DPI then the corresponding QPaintEngine must handle the resolution mapping.

In order to do this we use logicalDpiY method with the spin box object.

Syntax : spin_box.logicalDpiY()

Argument : It takes no argument

Return : It returns integer

Below is the implementation




# 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(1, 999999)
  
        # setting prefix to spin
        self.spin.setPrefix("PREFIX ")
  
        # setting suffix to spin
        self.spin.setSuffix(" SUFFIX")
  
        # creating a label
        label = QLabel(self)
  
        # making the label multi line
        label.setWordWrap(True)
  
        # setting geometry to the label
        label.setGeometry(100, 200, 200, 60)
  
        # getting the vertical logical dpi value
        value = self.spin.logicalDpiY()
  
        # setting text to the label
        label.setText("Vertical DPI(logical) : " + str(value))
  
  
# create pyqt5 app
App = QApplication(sys.argv)
  
# create the instance of our Window
window = Window()
  
# start the app
sys.exit(App.exec())


Output :



Similar Reads

PyQt5 QSpinBox - Getting Horizontal Logical DPI value
In this article we will see how we can get the horizontal resolution of the device in dots per inch(DPI) of the spin box. Logical dots per inch are used to convert font and user interface elements from point sizes to pixel sizes, and might be different from the physical dots per inch. Note : If the horizontal logical DPI doesn't equal to the physic
2 min read
PyQt5 QSpinBox - Getting vertical physical DPI
In this article we will see how we can get the vertical physical DPI of the spin box. DPI refers to the physical dot density of an image when it is reproduced as a real physical entity, for example printed onto paper. A digitally stored image has no inherent physical dimensions, measured in inches or centimeters. Vertical DPI is across y-axis. In o
2 min read
PyQt5 QSpinBox - Getting horizontal physical DPI
In this article we will see how we can get the horizontal physical DPI of the spin box. DPI refers to the physical dot density of an image when it is reproduced as a real physical entity, for example printed onto paper. A digitally stored image has no inherent physical dimensions, measured in inches or centimeters. In order to do this we use physic
2 min read
PyQt5 QSpinBox - Getting current value
In this article we will see how we can get the current value of the spin box. By default its value is 0 although user can change it any time and programmatically we use setValue method to change its value. In order to get the value of spin box we use value method Syntax : spin.value() Argument : It takes no argument Return : It returns integer i.e
2 min read
PyQt5 QSpinBox - Getting Pixel ratio as floating value
In this article we will see how we can get the pixel ratio of the spin box in the floating value, The device pixel ratio is the ratio between physical pixels and logical pixels of the spin box. Common values are 1 for normal-dpi displays and 2 for high-dpi "retina" displays. We can use devicePixelRatio method to get the pixel ratio but it is not in
2 min read
PyQt5 QSpinBox - Getting property value
In this article we will see how we can get the property value of the spin box, properties are the information added by the developer to tell about the properties of the spin box, for example, if spin box has ability to loop the values, the developer will add this property so that other developer can see this and get to know about the property. Prop
2 min read
PyQt5 QSpinBox - Getting the leading value of the font
In this article we will see how we can get the leading value of the spin box's font. Leading value of the text means the distance between two baselines of lines of type. The word 'leading' originates from the strips of lead hand-typesetters used to use to space out lines of text evenly. The word leading has stuck, but essentially it's a typographer
2 min read
PyQt5 QSpinBox - Getting the line spacing value of the text
In this article we will see how we can get the line spacing value of the spin box's text. Line spacing is the distance from one base line to the next. Line spacing value is always equal to the sum of leading value and height of the text. In order to do this we use lineSpacing method with the spin box's QFontMetrics object. Syntax : font_metrics.lin
2 min read
PyQt5 QSpinBox - Getting the minimum right bearing value of the font
In this article we will see how we can get the minimum right bearing of the spin box's font. Minimum right bearing value is the smallest rightBearing value of all characters in the font. The right bearing is the left-ward distance of the right-most pixel of the character from the logical origin of a subsequent character. This value is negative if t
2 min read
PyQt5 QSpinBox - Getting right bearing value of the text
In this article we will see how we can get right bearing value of the given character from spin box's text. The right bearing is the left-ward distance of the right-most pixel of the character from the logical origin of a subsequent character. This value is negative if the pixels of the character extend to the right of the width of the character. I
2 min read
Practice Tags :