Advertisement
programusy

zajonmc pyton

Mar 1st, 2023
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.71 KB | Haiku | 0 0
  1. import sys
  2. from PyQt5.QtWidgets import *
  3. from PyQt5.QtGui import QFont
  4. from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QTextEdit, QMainWindow
  5.  
  6. # def main():
  7. #     app = QApplication(sys.argv)
  8. #     widget = QWidget()
  9. #     label1 = QLabel(widget)
  10. #     label1.setText('Sebastian')
  11. #     label2 = QLabel(widget)
  12. #     label2.setText('Zajac \n3tsp')
  13. #     label2.setGeometry(300, 150, 50, 160)
  14. #     widget.setWindowTitle("wizytowka")
  15. #     widget.resize(640, 480)
  16. #
  17. #
  18. #     widget.show()
  19. #     app.exit(app.exec_())
  20. #
  21. # if __name__ == '__main__':
  22. #     main()
  23.  
  24. class Okno(QMainWindow):
  25.     def __init__(self):
  26.         super().__init__()
  27.         self.setWindowTitle("Okno na klasach")
  28.         self.label = QLabel('teskt', self)
  29.         self.label.setGeometry(0, 0, 1000, 20)
  30.         self.label.setFont(QFont('Verdana'))
  31.  
  32.         self.txtbox = QTextEdit('Ile kotow', self)
  33.         self.txtbox.setGeometry(0, 30, 100, 30)
  34.  
  35.         self.btn1 = QPushButton("Ok", self)
  36.         self.btn1.setGeometry(0, 70, 100, 20)
  37.         self.btn2 =QPushButton("Ala", self)
  38.         self.btn2.setGeometry(100, 70, 100, 20)
  39.  
  40.         self.btn1.clicked.connect(self.buttonOk)
  41.         self.btn2.clicked.connect(self.buttonAla)
  42.  
  43.         self.show()
  44.  
  45.     def buttonOk(self):
  46.         self.label.setText(self.txtbox.toPlainText())
  47.  
  48.         print('Ala ma koty w ilosci:', int(self.txtbox.toPlainText()))
  49.         print('Jej koty mają:', int(self.txtbox.toPlainText())*4, "nogi")
  50.  
  51.     def buttonAla(self):
  52.         self.label.setText("Ala ma kota.")
  53.  
  54.  
  55. def main():
  56.     app = QApplication(sys.argv)
  57.  
  58.     widget = Okno()
  59.     widget.resize(640, 480)
  60.  
  61.     app.exit(app.exec_())
  62.  
  63. if __name__ == '__main__':
  64.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement