scientific_comp_projects/CODE/[python]PYQT/test1.py

44 lines
941 B
Python
Raw Normal View History

2021-10-29 15:16:40 +02:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QApplication, QMainWindow
import sys
class MyWindow(QMainWindow):
def __init__(self):
super(MyWindow, self).__init__()
self.setGeometry(200, 200, 300, 300)
self.setWindowTitle('Here is the window')
self.initUI()
def initUI(self):
self.label = QtWidgets.QLabel(self)
self.label.setText('My first label!')
self.label.move(49,50)
self.b0 = QtWidgets.QPushButton(self)
self.b0.setText('Click here')
self.b0.clicked.connect(self.clicked)
def clicked(self):
self.label.setText('you pressed the button')
self.update()
def update(self):
self.label.adjustSize()
def clicked():
print('clicked')
def window():
app = QApplication(sys.argv)
win = MyWindow()
win.show()
sys.exit(app.exec_())
window()