Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- from PyQt5.QtWidgets import *
- from PyQt5.QtGui import QFont
- class Okno(QMainWindow):
- def __init__(self):
- super().__init__()
- self.setWindowTitle("ZOO")
- self.label = QLabel('ZOO ALI', self)
- self.label.setGeometry(80, 0, 50, 10)
- self.label.setFont(QFont('Verdana'))
- self.labelKoty = QLabel('Ile kotow', self)
- self.labelKoty.setGeometry(0, 20, 70, 30)
- self.txtKoty = QTextEdit(self)
- self.txtKoty.setGeometry(100, 20, 70, 30)
- self.labelKanarki = QLabel('Ile kanarkow', self)
- self.labelKanarki.setGeometry(0, 50, 70, 30)
- self.txtKanarki = QTextEdit(self)
- self.txtKanarki.setGeometry(100, 50, 70, 30)
- self.labelRybki = QLabel('Ile rybek', self)
- self.labelRybki.setGeometry(0, 80, 70, 30)
- self.txtRybki = QTextEdit(self)
- self.txtRybki.setGeometry(100, 80, 70, 30)
- self.labelNogi = QLabel('Liczba nog: 0', self)
- self.labelNogi.setGeometry(0, 120, 70, 30)
- self.labelOgony = QLabel('Liczba ogonow: 0', self)
- self.labelOgony.setGeometry(0, 150, 100, 30)
- self.btn1 = QPushButton("Oblicz", self)
- self.btn1.setGeometry(200, 55, 50, 20)
- self.btn1.clicked.connect(self.buttonOblicz)
- self.show()
- def buttonOblicz(self):
- liczbaNog = int(self.txtKoty.toPlainText()) * 4 + int(self.txtKanarki.toPlainText()) * 2
- liczbaOgonow = int(self.txtKoty.toPlainText()) + int(self.txtKanarki.toPlainText()) + int(self.txtRybki.toPlainText())
- self.labelNogi.setText('Liczba nog: ' + str(liczbaNog))
- self.labelOgony.setText('Liczba ogonow: ' + str(liczbaOgonow))
- def main():
- app = QApplication(sys.argv)
- widget = Okno()
- widget.resize(250, 300)
- app.exit(app.exec_())
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement