diff --git a/exampledata.py b/exampledata.py new file mode 100644 index 0000000..34cbd27 --- /dev/null +++ b/exampledata.py @@ -0,0 +1,17 @@ +import numpy as np + + +X = np.arange(100) / 10 + +exampledata = { + "sine": [X, np.sin(X)], + "cosine": [X, np.cos(X)], + "exp": [X, np.exp(X)], + "log": [X, np.log(X+1)] +} + +# due to the appending of xy pairs, data needs to be transposed +exampledata = {k: zip(*v) for k, v in exampledata.items()} + + + diff --git a/mainwin.py b/mainwin.py index b81fa17..31a5353 100644 --- a/mainwin.py +++ b/mainwin.py @@ -1,5 +1,3 @@ -import numpy as np - from PyQt5.QtCore import Qt, pyqtSignal from PyQt5.QtWidgets import QMainWindow, QSplitter @@ -7,9 +5,7 @@ import assets from dictlist import DictList from mdi import MDIArea, MDISubPlot from rpcserverthread import RPCServerThread - - -X = np.arange(100) / 10 +from exampledata import exampledata class MainWindow(QMainWindow): @@ -21,14 +17,7 @@ class MainWindow(QMainWindow): self.setWindowTitle(title) self.setWindowIcon(assets.icon()) - data = { - "sine": [X, np.sin(X)], - "cosine": [X, np.cos(X)], - "exp": [X, np.exp(X)], - "log": [X, np.log(X+1)] - } - data = {k: zip(*v) for k, v in data.items()} # due to the appending of xy pairs, data needs to be transposed - self.lst = lst = DictList(data) + self.lst = lst = DictList(exampledata) lst.setAlternatingRowColors(True) lst.doubleClicked.connect(self.on_select_list_item) self.setCentralWidget(lst)