Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import time
- from PySide6.QtCore import QThread
- from PySide6.QtWidgets import (QApplication, QWidget, QPushButton, QComboBox, QVBoxLayout)
- class Gui(QWidget):
- def __init__(self):
- super().__init__()
- layout = QVBoxLayout()
- button = QPushButton('click me')
- button.clicked.connect(self.do_task)
- combobox = QComboBox()
- combobox.addItems(['1', '2', '3', '4', '5'])
- layout.addWidget(button)
- layout.addWidget(combobox)
- self.setLayout(layout)
- def algo(self):
- print('task started')
- k = 0
- for i in range(100):
- for j in range(100):
- k += 1
- print(k)
- time.sleep(0.5)
- print('task finished')
- def do_task(self):
- self.thread = QThread()
- self.thread.run = self.algo
- self.thread.start()
- if __name__ == '__main__':
- app = QApplication(sys.argv)
- window = Gui()
- window.show()
- sys.exit(app.exec())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement