QObject e QThread: criando a janela inicial com Qt Designer

This commit is contained in:
Luiz Otávio
2023-03-11 09:55:13 -03:00
parent a04c0304e7
commit 09bfb032eb
3 changed files with 144 additions and 0 deletions

17
aula204/main.py Normal file
View File

@@ -0,0 +1,17 @@
import sys
from PySide6.QtWidgets import QApplication, QWidget
from ui_workerui import Ui_myWidget
class MyWidget(QWidget, Ui_myWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.setupUi(self)
if __name__ == '__main__':
app = QApplication(sys.argv)
myWidget = MyWidget()
myWidget.show()
app.exec()

69
aula204/ui_workerui.py Normal file
View File

@@ -0,0 +1,69 @@
# -*- coding: utf-8 -*-
################################################################################
## Form generated from reading UI file 'workerui.ui'
##
## Created by: Qt User Interface Compiler version 6.4.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
QMetaObject, QObject, QPoint, QRect,
QSize, QTime, QUrl, Qt)
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
QFont, QFontDatabase, QGradient, QIcon,
QImage, QKeySequence, QLinearGradient, QPainter,
QPalette, QPixmap, QRadialGradient, QTransform)
from PySide6.QtWidgets import (QApplication, QGridLayout, QHBoxLayout, QLabel,
QPushButton, QSizePolicy, QWidget)
class Ui_myWidget(object):
def setupUi(self, myWidget):
if not myWidget.objectName():
myWidget.setObjectName(u"myWidget")
myWidget.resize(400, 300)
font = QFont()
font.setPointSize(40)
myWidget.setFont(font)
self.horizontalLayout = QHBoxLayout(myWidget)
self.horizontalLayout.setObjectName(u"horizontalLayout")
self.gridLayout = QGridLayout()
self.gridLayout.setObjectName(u"gridLayout")
self.label2 = QLabel(myWidget)
self.label2.setObjectName(u"label2")
self.gridLayout.addWidget(self.label2, 0, 1, 1, 1)
self.label1 = QLabel(myWidget)
self.label1.setObjectName(u"label1")
self.gridLayout.addWidget(self.label1, 0, 0, 1, 1)
self.button1 = QPushButton(myWidget)
self.button1.setObjectName(u"button1")
self.gridLayout.addWidget(self.button1, 1, 0, 1, 1)
self.button2 = QPushButton(myWidget)
self.button2.setObjectName(u"button2")
self.gridLayout.addWidget(self.button2, 1, 1, 1, 1)
self.horizontalLayout.addLayout(self.gridLayout)
self.retranslateUi(myWidget)
QMetaObject.connectSlotsByName(myWidget)
# setupUi
def retranslateUi(self, myWidget):
myWidget.setWindowTitle(QCoreApplication.translate("myWidget", u"Form", None))
self.label2.setText(QCoreApplication.translate("myWidget", u"L2", None))
self.label1.setText(QCoreApplication.translate("myWidget", u"L1", None))
self.button1.setText(QCoreApplication.translate("myWidget", u"B1", None))
self.button2.setText(QCoreApplication.translate("myWidget", u"B2", None))
# retranslateUi

58
aula204/workerui.ui Normal file
View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>myWidget</class>
<widget class="QWidget" name="myWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>40</pointsize>
</font>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QLabel" name="label2">
<property name="text">
<string>L2</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label1">
<property name="text">
<string>L1</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="button1">
<property name="text">
<string>B1</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="button2">
<property name="text">
<string>B2</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>