Added missing files and removed unnessesary ones
This commit is contained in:
61
Python/pyqt6_4/snippets/10.py
Executable file
61
Python/pyqt6_4/snippets/10.py
Executable file
@ -0,0 +1,61 @@
|
||||
import sys
|
||||
|
||||
from PyQt6.QtWidgets import (
|
||||
QApplication,
|
||||
QWidget,
|
||||
QHBoxLayout,
|
||||
QSpinBox,
|
||||
QLabel,
|
||||
QLineEdit,
|
||||
)
|
||||
from PyQt6.QtGui import QFont
|
||||
|
||||
|
||||
class Window(QWidget):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.setGeometry(*(500,) * 4)
|
||||
self.setWindowTitle("Окно")
|
||||
self.price = 300
|
||||
self.amount = 0
|
||||
|
||||
hbox = QHBoxLayout()
|
||||
|
||||
self.line_edit = QLineEdit(str(self.price))
|
||||
self.line_edit.setFont(QFont("Times", 14))
|
||||
|
||||
self.spin_box = QSpinBox()
|
||||
self.spin_box.valueChanged.connect(self.handle_spin_box)
|
||||
self.result = QLabel(str(self.total))
|
||||
|
||||
hbox.addWidget(self.line_edit)
|
||||
hbox.addWidget(self.spin_box)
|
||||
hbox.addWidget(self.result)
|
||||
|
||||
self.setLayout(hbox)
|
||||
|
||||
def handle_spin_box(self) -> None:
|
||||
try:
|
||||
self.price = int(self.line_edit.text())
|
||||
except ValueError:
|
||||
return
|
||||
self.amount = self.spin_box.value()
|
||||
self.result.setText(str(self.total))
|
||||
|
||||
@property
|
||||
def total(self) -> int:
|
||||
return self.amount * self.price
|
||||
|
||||
def handle_line_edit(self) -> None:
|
||||
pass
|
||||
|
||||
|
||||
def main() -> None:
|
||||
app = QApplication(sys.argv)
|
||||
window = Window()
|
||||
window.show()
|
||||
sys.exit(app.exec())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in New Issue
Block a user