Weiss jemand wie man QThread dazu bewegt die GUI (Progressbar und MainWindow) nicht zu blocken auch wenn QThread ne 100% CPU Last erzeugt?
Habs schon mit wait() und der priorität versucht aber sobald der Thread läuft und die CPU auf 100% knallt bleibt der ProgressBarDialog und das MainWindow hängen :/
Kann jemand helfen?
Code: Alles auswählen
def onButtonApply(self):
self.progressBar = QtGui.QProgressDialog(self, QtCore.Qt.FramelessWindowHint) #QtCore.Qt.X11BypassWindowManagerHint)
self.progressBar.setRange(0,0)
self.progressBar.setLabelText(self.tr('Please wait'))
self.progressBar.setCancelButton(None)
self.progressBar.show()
self.thread = Thread(str(self.lineDevice.text()), str(self.lineMount.text()), str(self.comboBox.currentText()), str(self.linePassphrase.text()), str(self.lineKeyfile.text()))
self.thread.start()
self.connect(self.thread, QtCore.SIGNAL('finished()'), self.onFinish)
class Thread(QtCore.QThread):
def __init__(self, device, mountpoint, fs, passphrase, key_file):
QtCore.QThread.__init__(self)
self.device = device
self.mountpoint = mountpoint
self.fs = fs
self.passphrase = passphrase
self.key_file = key_file
def run(self):
if os.path.isfile(self.device):
lo = addLoop(self.device)
luksID= 'luks-' + luks_uuid(lo[1])
luks_open(lo[1], luksID, self.passphrase, self.key_file)
mountDevice(self.mountpoint, '/dev/mapper/' + luksID, self.fs)
else:
luksID = 'luks-' + luks_uuid(self.device)
luks_open(self.device, luksID, self.passphrase, self.key_file)
mountDevice(self.mountpoint, '/dev/mapper/' + luksID, self.fs)