Advertisement
programusy

Untitled

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