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
- from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QTextEdit, QMainWindow
- # def main():
- # app = QApplication(sys.argv)
- # widget = QWidget()
- # label1 = QLabel(widget)
- # label1.setText('Sebastian')
- # label2 = QLabel(widget)
- # label2.setText('Zajac \n3tsp')
- # label2.setGeometry(300, 150, 50, 160)
- # widget.setWindowTitle("wizytowka")
- # widget.resize(640, 480)
- #
- #
- # widget.show()
- # app.exit(app.exec_())
- #
- # if __name__ == '__main__':
- # main()
- class Okno(QMainWindow):
- def __init__(self):
- super().__init__()
- self.setWindowTitle("Okno na klasach")
- self.label = QLabel('teskt', self)
- self.label.setGeometry(0, 0, 1000, 20)
- self.label.setFont(QFont('Verdana'))
- self.txtbox = QTextEdit('Ile kotow', self)
- self.txtbox.setGeometry(0, 30, 100, 30)
- self.btn1 = QPushButton("Ok", self)
- self.btn1.setGeometry(0, 70, 100, 20)
- self.btn2 =QPushButton("Ala", self)
- self.btn2.setGeometry(100, 70, 100, 20)
- self.btn1.clicked.connect(self.buttonOk)
- self.btn2.clicked.connect(self.buttonAla)
- self.show()
- def buttonOk(self):
- self.label.setText(self.txtbox.toPlainText())
- print('Ala ma koty w ilosci:', int(self.txtbox.toPlainText()))
- print('Jej koty mają:', int(self.txtbox.toPlainText())*4, "nogi")
- def buttonAla(self):
- self.label.setText("Ala ma kota.")
- def main():
- app = QApplication(sys.argv)
- widget = Okno()
- widget.resize(640, 480)
- app.exit(app.exec_())
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement