forked from HaeffnerLab/RealSimpleGrapher
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphWindow.py
More file actions
90 lines (79 loc) · 3.17 KB
/
GraphWindow.py
File metadata and controls
90 lines (79 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
"""
The main GUI which holds everything and puts everything together.
"""
import GUIConfig
from PyQt5.QtWidgets import QWidget, QGridLayout
from RealSimpleGrapher.pyqtgraph_widgets import *
from EGGS_labrad.clients.Widgets import QDetachableTabWidget
class GridGraphWindow(QWidget):
"""
Window containing a grid of graphs.
Holds an individual RSG tab page.
"""
def __init__(self, g_list, row_list, column_list, reactor, parent=None):
super(GridGraphWindow, self).__init__(parent)
self.reactor = reactor
# set background
self.setStyleSheet("background-color:black; color:white")
# initialize the UI
self.initUI(g_list, row_list, column_list)
def initUI(self, g_list, row_list, column_list):
layout = QGridLayout(self)
for k in range(len(g_list)):
layout.addWidget(g_list[k], row_list[k], column_list[k])
class GraphWindow(QDetachableTabWidget):
"""
The main RSG GUI which does nearly everything.
Creates the RSG GUI from GUIConfig.py.
Each tab is a GridGraphWindow object, which consists of _PyQtGraph objects.
"""
def __init__(self, reactor, cxn=None, parent=None, root=None):
"""
Initialize self variables and set up the GUI.
"""
# initialize the PyQt object
super(GraphWindow, self).__init__()
# initialize self variables
self.cxn = cxn
self.parent = parent
self.reactor = reactor
self.root = root
# initialize the UI
self.initUI()
# set background
self.setStyleSheet("background-color:black")
def initUI(self):
reactor = self.reactor
# create dictionaries to hold the graphs and tabs
self.graphDict = {}
self.tabDict = {}
# create the individual tabs
for gc in GUIConfig.tabs:
# gcli = graph config list
gcli = gc.config_list
gli = []
for config in gcli:
name = config.name
if config.isImages:
graph_tmp = ImageWidget(reactor, config)
self.graphDict[name] = graph_tmp
gli.append(graph_tmp)
continue
elif config.isHist:
graph_tmp = Hist_PyQtGraph(reactor, config, cxn=self.cxn, root=self.root)
self.graphDict[name] = graph_tmp
gli.append(graph_tmp)
continue
else:
graph_tmp = Graph_PyQtGraph(reactor, config, cxn=self.cxn, root=self.root)
graph_tmp.set_ylimits(config.ylim)
self.graphDict[name] = graph_tmp
gli.append(graph_tmp)
widget = GridGraphWindow(gli, gc.row_list, gc.column_list, reactor)
self.tabDict[name] = widget
self.addTab(widget, gc.tab)
self.setMovable(True)
def insert_tab(self, tab):
graph_tmp = Graph_PyQtGraph(tab, self.reactor, cxn=self.cxn, root=self.root)
self.graphDict[tab] = graph_tmp
self.addTab(graph_tmp, tab)