71 lines
1.7 KiB
Python
Executable File
71 lines
1.7 KiB
Python
Executable File
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()
|