Calculadora - Criando a janela principal com QMainWindow, QWidget e QVBoxLayout
This commit is contained in:
16
aula202-calculadora/main.py
Normal file
16
aula202-calculadora/main.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import sys
|
||||
|
||||
from main_window import MainWindow
|
||||
from PySide6.QtWidgets import QApplication, QLabel
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
window = MainWindow()
|
||||
|
||||
label1 = QLabel('O meu texto')
|
||||
label1.setStyleSheet('font-size: 150px;')
|
||||
window.v_layout.addWidget(label1)
|
||||
window.adjustFixedSize()
|
||||
|
||||
window.show()
|
||||
app.exec()
|
||||
20
aula202-calculadora/main_window.py
Normal file
20
aula202-calculadora/main_window.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from PySide6.QtWidgets import QMainWindow, QVBoxLayout, QWidget
|
||||
|
||||
|
||||
class MainWindow(QMainWindow):
|
||||
def __init__(self, parent: QWidget | None = None, *args, **kwargs) -> None:
|
||||
super().__init__(parent, *args, **kwargs)
|
||||
|
||||
# Configurando o layout básico
|
||||
self.cw = QWidget()
|
||||
self.v_layout = QVBoxLayout()
|
||||
self.cw.setLayout(self.v_layout)
|
||||
self.setCentralWidget(self.cw)
|
||||
|
||||
# Título da janela
|
||||
self.setWindowTitle('Calculadora')
|
||||
|
||||
def adjustFixedSize(self):
|
||||
# Última coisa a ser feita
|
||||
self.adjustSize()
|
||||
self.setFixedSize(self.width(), self.height())
|
||||
Reference in New Issue
Block a user