Commit 89180a1e authored by Yan's avatar Yan
Browse files

Console history, fixed config

* removed bug induced by commit 9720776c
* rewrote console dock - console has history now
parent 60009e5a
......@@ -282,7 +282,7 @@ def main():
treedock = docks.treeDockWidget(
"&File browser", "view/filebrowservisible", update, load_file,
main_window, augCanvas, config, loadthread)
paramsdock = docks.augDock("Acquisition parameters", "&Acq parameters",
paramsdock = docks.AugDock("Acquisition parameters", "&Acq parameters",
update.signal.connect(lambda: gt.update_paramstable(augCanvas))
......@@ -20,7 +20,7 @@ def settings():
("imggen/yinch", 4),
("imggen/dpi", 300),
("imggen/xtics", 5)}
[print("will set value", i[0])
for i in defvals if not settings.contains(i[0])]
return settings
#!/usr/bin/env python3
from PyQt5 import QtWidgets
from PyQt5 import QtCore
from code import InteractiveConsole
from io import StringIO
from os import path
......@@ -8,11 +9,11 @@ import contextlib
import prasopes.config as cf
class augDock(QtWidgets.QDockWidget):
class AugDock(QtWidgets.QDockWidget):
"""construct dock with vboxlayout and action to show/hide"""
def __init__(self, name, actionname, cfval):
config = cf.settings()
QtWidgets.QDockWidget.__init__(self, name)
self.layout = QtWidgets.QVBoxLayout(self.widget())
self.action = QtWidgets.QAction(
......@@ -31,6 +32,27 @@ class augDock(QtWidgets.QDockWidget):
class AugLineEdit(QtWidgets.QLineEdit):
"""QLineEdit with history"""
def __init__(self):
self.history = []
self.historypos = 0
self.returnPressed.connect(lambda: self.history.append(self.text())
if self.text() != "" else None)
def keyPressEvent(self, event):
"""super().keyPressEvent override"""
if event.key() in (QtCore.Qt.Key_Up, QtCore.Qt.Key_Down):
self.historypos = min(len(self.history), self.historypos+1) if\
event.key() == QtCore.Qt.Key_Up else max(0, self.historypos-1)
if self.historypos > 0 else self.setText("")
self.historypos = 0
def consoleDockWidget(localvars, actionname, cfval):
def consoleExecfunc(inp, outp, loc):
stream = StringIO()
......@@ -49,10 +71,10 @@ def consoleDockWidget(localvars, actionname, cfval):
outtext = stream.getvalue()
if outtext != "":
dock = augDock("console", actionname, cfval)
dock = AugDock("console", actionname, cfval)
coutput = QtWidgets.QTextEdit()
cinput = QtWidgets.QLineEdit()
cinput = AugLineEdit()
cinput.returnPressed.connect(lambda: consoleExecfunc(
cinput, coutput, localvars))
[dock.layout.addWidget(i) for i in (coutput, cinput)]
......@@ -71,7 +93,7 @@ def treeDockWidget(actionname, cfval, update, loadfnc, parent,
dirview = QtWidgets.QListView()
dock = augDock("Folder View", actionname, cfval)
dock = AugDock("Folder View", actionname, cfval)
[dock.layout.addWidget(i) for i in (treeview, dirview)]
def scrolltoonce():
Supports Markdown
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