The GUI in Qt helps organize and synchronize a number of parameters:
- Kernel functions (Core) with their requirements for the installation environment and the order of implementation of variables
- Widgets in Qt are represented as memory-allocated code blocks, implemented in
.py
and described in XML in.ui
- The organization follows a principle similar to the connection between JavaScript, HTML and CSS
font = QtGui.QFont()
font.setPointSize(10)
self.pushButton.setFont(font)
self.pushButton.setStyleSheet("background-color: rgb(255, 255, 255);")
self.pushButton.setObjectName("pushButton")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 1126, 26))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
After connecting the QtGui library, we can set the parameters and widgets we need on the graphical interface, while simultaneously naming them for the code.
Various classes, such as QPushButton
, QMenuBar
, QStatusBar
, determine the coverage area of a particular object. Various modules resemble API methods in structure, and when you call each one you get the expected call.
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>750</x>
<y>570</y>
<width>311</width>
<height>51</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>Analyze</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1126</width>
<height>26</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
Don’t forget to describe each of the listed classes in XML for the correct layout of files when launched. Gui provides only the output image; you write the entire backend in other Qt modules.
It's better to store project files in one place, which will avoid explicitly writing their paths in the computer memory. If it's possible not to produce more files, write to everything in one. Python, unlike Java/C/Kotlin, doesn't allow structures that are difficult to compile.
Top comments (0)