Commit dec50bbd authored by 3Yan's avatar 3Yan
Browse files

Fixed loadthread handling - not freezing in W10

* Finally fixed the thread handling for loading file
* minor flake8 cleanup - graphtools pan_factory defocus routine
parent d100d636
......@@ -89,13 +89,10 @@ def load_file(parent, augCanvas, update, settings, loadthread, filename=None):
error.signal.emit()
gt.populate(augCanvas)
augCanvas.filename = filename
parent.setWindowTitle("Prasopes - {}".format(
os.path.basename(filename)))
oldrecents = settings.value("recents")
oldrecents.remove(filename) if filename in oldrecents else None
settings.setValue("recents", [filename, *oldrecents])
update.signal.emit()
loadthread.quit()
error.signal.connect(lambda: QtWidgets.QMessageBox.critical(
parent, errormsg[0], errormsg[1]))
loadthread.run = runfnc
......@@ -148,6 +145,7 @@ def update_spectrum(augCanvas, config):
def update_recents(rcm, main_window, augCanvas, update, config, loadthread):
"""updates recents_menu (rcm)"""
rcm.clear()
# Actions need to be stored somewhere. Otherwise they end up in garbage.
rcm.actionCache = []
......@@ -248,6 +246,8 @@ def main():
barHandler.setLevel("DEBUG")
main_window = QtWidgets.QMainWindow(windowTitle="Prasopes")
update.signal.connect(lambda: main_window.setWindowTitle(
"Prasopes - {}".format(os.path.basename(augCanvas.filename))))
if QtGui.QIcon.themeName() == "":
QtGui.QIcon.setThemeName("TangoMFK")
......
......@@ -160,9 +160,9 @@ def zoom_factory(axis, base_scale, plot_data=None):
def pan_factory(axis, plot=None):
"""pan spectrum when you press a button"""
def pan_fun(event, ax, pd):
#remove focus from other objects when clicking on graph
# Release focus from other objects when clicking on graph.
focusedWidget = QtWidgets.QApplication.focusWidget()
if focusedWidget != None and event.inaxes == ax:
if focusedWidget and event.inaxes == ax:
focusedWidget.clearFocus()
# re-scale to origin if doubleclicked
if event.dblclick and event.inaxes == ax:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment