-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwidgets.py
More file actions
78 lines (62 loc) · 2.27 KB
/
Copy pathwidgets.py
File metadata and controls
78 lines (62 loc) · 2.27 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
from silx.gui import qt
class OddSpinBox(qt.QSpinBox):
"""A spin box that only allows odd numbers."""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.valueChanged.connect(self.ensure_odd)
def ensure_odd(self, value):
if value % 2 == 0:
if value == self.maximum():
self.setValue(value - 1)
else:
self.setValue(value + 1)
def stepBy(self, steps):
super().stepBy(steps*2)
class MainToolBar(qt.QToolBar):
"""
Toolbar composed of labeld buttons
"""
sigSetPannel = qt.Signal(object)
def __init__(self, parent=None, *args, **kwargs):
super().__init__(parent, *args, **kwargs)
# Setup font
self.font = qt.QFont("Verdana", 12)
# Mode action group
self.actionGroup = qt.QActionGroup(self)
# Align right
self.setLayoutDirection(qt.Qt.LeftToRight)
# Build actions
self.buildActions()
def buildActions(self):
# Make pre-processing button
action = qt.QAction("Preprocessing", self)
action.setFont(self.font)
action.setCheckable(True)
action.setActionGroup(self.actionGroup)
action.triggered.connect(lambda: self.sigSetPannel.emit("Preprocessing"))
self.addAction(action)
action.trigger()
# Make spearator
label = qt.QAction(" | ", self)
label.setFont(self.font)
label.setDisabled(True)
self.addAction(label)
# Make fitting button
action = qt.QAction("Fitting", self)
action.setFont(self.font)
action.setCheckable(True)
action.setActionGroup(self.actionGroup)
action.triggered.connect(lambda: self.sigSetPannel.emit("Fitting"))
self.addAction(action)
# Make spearator
label = qt.QAction(" | ", self)
label.setFont(self.font)
label.setDisabled(True)
self.addAction(label)
# Make Spectrum Viewer button
action = qt.QAction("Spectrum Viewer", self)
action.setFont(self.font)
action.setCheckable(True)
action.setActionGroup(self.actionGroup)
action.triggered.connect(lambda: self.sigSetPannel.emit("Spectrum Viewer"))
self.addAction(action)