Added missing files and removed unnessesary ones

This commit is contained in:
2023-07-16 16:44:42 +03:00
parent c3fa5367c3
commit 199dd693e4
41 changed files with 1442 additions and 50 deletions

70
Python/pyqt6_4/snippets/9.py Executable file
View File

@ -0,0 +1,70 @@
import sys
from enum import StrEnum
from PyQt6.QtGui import QFont
from PyQt6.QtWidgets import (
QApplication,
QComboBox,
QHBoxLayout,
QLabel,
QVBoxLayout,
QWidget,
)
class CatType(StrEnum):
ORANGE = "one orange brain cell"
VOID = "void"
DUST = "dust kitty"
class Window(QWidget):
def __init__(self) -> None:
super().__init__()
self.setGeometry(*(500,) * 4)
self.setWindowTitle("Окно")
self.current_type = CatType.ORANGE
self.create_combo()
def create_combo(self) -> None:
hbox = QHBoxLayout()
label = QLabel("Select cat type:")
label.setFont(QFont("Times", 15))
self.combo = QComboBox(self)
for cat_type in CatType:
self.combo.addItem(cat_type.capitalize())
self.combo.currentTextChanged.connect(self.combo_changed)
hbox.addWidget(label)
hbox.addWidget(self.combo)
vbox = QVBoxLayout()
self.label_result = QLabel(
f"Current cat: {self.current_type.capitalize()}",
)
self.label_result.setFont(QFont("Times", 15))
vbox = QVBoxLayout()
vbox.addWidget(self.label_result)
vbox.addLayout(hbox)
self.setLayout(vbox)
def combo_changed(self) -> None:
self.current_type = CatType(self.combo.currentText().lower())
self.label_result.setText(
f"Current cat: {self.current_type.capitalize()}",
)
def main() -> None:
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec())
if __name__ == "__main__":
main()