Advertisement
programusy

Igorus

Mar 8th, 2023
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1.  
  2.  
  3.  
  4. import sys
  5. from PyQt5.QtWidgets import *
  6. from PyQt5.QtGui import QFont
  7.  
  8.  
  9. class Okno(QMainWindow):
  10.     def __init__(self):
  11.         super().__init__()
  12.  
  13.         self.setWindowTitle("ZOO Ali")
  14.         self.label = QLabel('ZOO Ali’, self)
  15.         self.label.setGeometry(80, 0, 50, 10)
  16.  
  17.         self.labelKoty = QLabel('Ile kotow', self)
  18.         self.labelKoty.setGeometry(0, 20, 70, 30)
  19.         self.tk = QTextEdit(self)
  20.         self.tk.setGeometry(100, 20, 70, 30)
  21.  
  22.         self.labelKanarki = QLabel('Ile kanarkow', self)
  23.         self.labelKanarki.setGeometry(0, 50, 70, 30)
  24.         self.tkn = QTextEdit(self)
  25.         self.tkn.setGeometry(100, 50, 70, 30)
  26.  
  27.         self.labelRybki = QLabel('Ile rybek', self)
  28.         self.labelRybki.setGeometry(0, 80, 70, 30)
  29.         self.tr = QTextEdit(self)
  30.         self.tr.setGeometry(100, 80, 70, 30)
  31.  
  32.         self.Nogi = QLabel('Liczba nog: 0', self)
  33.         self.Nogi.setGeometry(0, 120, 70, 30)
  34.         self.Ogony = QLabel('Liczba ogonow: 0', self)
  35.         self.Ogony.setGeometry(0, 150, 100, 30)
  36.  
  37.         self.btn1 = QPushButton("Oblicz", self)
  38.         self.btn1.setGeometry(200, 55, 50, 20)
  39.  
  40.         self.btn1.clicked.connect(self.buttonOblicz)
  41.  
  42.         self.show()
  43.  
  44.     def buttonOblicz(self):
  45.         liczbaNog = int(self.tk.toPlainText()) * 4 + int(self.tkn.toPlainText()) * 2
  46.         liczbaOgonow = int(self.tk.toPlainText()) + int(self.tkn.toPlainText()) + int(self.tr.toPlainText())
  47.  
  48.         self.labelNogi.setText('Liczba nog: ' + str(liczbaNog))
  49.         self.labelOgony.setText('Liczba ogonow: ' + str(liczbaOgonow))
  50.  
  51.  
  52. def main():
  53.     app = QApplication(sys.argv)
  54.  
  55.     widget = Okno()
  56.     widget.resize(250, 300)
  57.  
  58.     app.exit(app.exec_())
  59.  
  60.  
  61. if __name__ == '__main__':
  62.     main()
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement