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 Ali")
- self.label = QLabel('ZOO Ali’, self)
- self.label.setGeometry(80, 0, 50, 10)
- self.labelKoty = QLabel('Ile kotow', self)
- self.labelKoty.setGeometry(0, 20, 70, 30)
- self.tk = QTextEdit(self)
- self.tk.setGeometry(100, 20, 70, 30)
- self.labelKanarki = QLabel('Ile kanarkow', self)
- self.labelKanarki.setGeometry(0, 50, 70, 30)
- self.tkn = QTextEdit(self)
- self.tkn.setGeometry(100, 50, 70, 30)
- self.labelRybki = QLabel('Ile rybek', self)
- self.labelRybki.setGeometry(0, 80, 70, 30)
- self.tr = QTextEdit(self)
- self.tr.setGeometry(100, 80, 70, 30)
- self.Nogi = QLabel('Liczba nog: 0', self)
- self.Nogi.setGeometry(0, 120, 70, 30)
- self.Ogony = QLabel('Liczba ogonow: 0', self)
- self.Ogony.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.tk.toPlainText()) * 4 + int(self.tkn.toPlainText()) * 2
- liczbaOgonow = int(self.tk.toPlainText()) + int(self.tkn.toPlainText()) + int(self.tr.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