Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QLineEdit, QPushButton, QVBoxLayout
- class Okno(QWidget):
- def __init__(self):
- super().__init__()
- self.koty_label = QLabel("Ilość kotów:")
- self.koty_entry = QLineEdit()
- self.ryby_label = QLabel("Ilość ryb:")
- self.ryby_entry = QLineEdit()
- self.kanar_label = QLabel("Ilość kanarków:")
- self.kanar_entry = QLineEdit()
- self.wynik_label = QLabel()
- self.oblicz_button = QPushButton("Oblicz")
- self.oblicz_button.clicked.connect(self.oblicz_nogi)
- vbox = QVBoxLayout()
- vbox.addWidget(self.koty_label)
- vbox.addWidget(self.koty_entry)
- vbox.addWidget(self.ryby_label)
- vbox.addWidget(self.ryby_entry)
- vbox.addWidget(self.kanar_label)
- vbox.addWidget(self.kanar_entry)
- vbox.addWidget(self.oblicz_button)
- vbox.addWidget(self.wynik_label)
- self.setLayout(vbox)
- def oblicz_nogi(self):
- ilosc_kotow = int(self.koty_entry.text())
- ilosc_ryb = int(self.ryby_entry.text())
- ilosc_kanar = int(self.kanar_entry.text())
- suma_nog = 4 * ilosc_kotow + 0 * ilosc_ryb + 2 * ilosc_kanar
- self.wynik_label.setText("Ilość nóg: " + str(suma_nog))
- if __name__ == '__main__':
- app = QApplication(sys.argv)
- okno = Okno()
- okno.show()
- sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement