Skip to content
Snippets Groups Projects
Commit 4790a46c authored by Daniel Meißner's avatar Daniel Meißner Committed by Daniel Meißner
Browse files

gui: added processbar code and played with threading

parent 63f7df0f
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,8 @@ from lib.disk import Disk
from lib.gr.file_sink import FileSink
from lib.gui.update_progress_bar import UpdateProgressBar
class SuGui(QtWidgets.QMainWindow):
"""
GUI class used to realise the main window.
......@@ -87,9 +89,24 @@ class SuGui(QtWidgets.QMainWindow):
self.button_stop.setEnabled(True)
self.button_start.setEnabled(False)
file_sink.capture()
# Thread stuff
self.request = UpdateProgressBar(options['capture_time'])
print(self.__class__)
self.connect(self.request, QtCore.SIGNAL("mysignal(QString)"), self.update_progress_bar, QtCore.Qt.QueuedConnection)
self.request.start()
#file_sink.capture()
def update_progress_bar(self, text):
"""
Add the text that's given to this function to the
list_submissions QListWidget we have in our GUI and
increase the current value of progress bar by 1
:param text: text to add to the process bar
:type text: str
"""
self.progress_bar.setValue(text)
def stop_button(self):
"""
......
# -*- coding: utf-8 -*-
import time
from PyQt5.QtCore import QThread, pyqtSignal
class UpdateProgressBar(QThread):
update_pb = pyqtSignal('QString', name='updateProgressBar')
def __init__(self, measure_time):
"""
Make a new thread instance.
:param measure_time: Time to measure spectrum
:type measure_time: int
"""
QThread.__init__(self)
self.measure_time = measure_time
self.start_time = float(time.time())
def __del__(self):
self.wait()
def run(self):
while self.sleep(2):
#self.update_pb.emit(SIGNAL('update_progress_bar(QString)'), \ time_to_percent)
self.emit(QtCore.SIGNAL("mysignal(QString)"), time_to_percent)
def time_to_percent(self):
running_time = float(time.time()) - self.start_time
percent = (running_time/self.measure_time)*100
return int(percent)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment