123456789101112131415161718192021222324252627282930313233343536 |
- #!/usr/bin/env python
- from PyQt5 import QtCore, QtGui, QtWidgets
- from PyQt5.QtWidgets import QApplication, QMainWindow
- import sys
- class MyWindow(QMainWindow):
- def __init__(self):
- super(MyWindow, self).__init__()
- self.setGeometry(0, 0, 300, 300)
- self.setWindowTitle("Time Tracker")
- self.initUI()
- def initUI(self):
- self.label = QtWidgets.QLabel(self)
- self.label.setText("my first label!")
- self.label.move(50, 50)
- self.b1 = QtWidgets.QPushButton(self)
- self.b1.setText("Click me")
- self.b1.clicked.connect(self.clicked)
- def clicked(self):
- self.label.setText("you pressed the button")
- self.update()
- def update(self):
- self.label.adjustSize()
- def window():
- app = QApplication(sys.argv)
- win = MyWindow()
- win.show()
- sys.exit(app.exec_())
- window()
|