Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.corrShape = None
self.cropShape = None
self.xlim = None
self.ylim = None
self.shape = self.main.shape
# Title
recTitle = QtGui.QLabel('<h2><strong>Recording</strong></h2>')
recTitle.setTextFormat(QtCore.Qt.RichText)
self.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
# Folder and filename fields
self.folderEdit = QtGui.QLineEdit(self.initialDir)
openFolderButton = QtGui.QPushButton('Open')
openFolderButton.clicked.connect(self.openFolder)
loadFolderButton = QtGui.QPushButton('Browse')
loadFolderButton.clicked.connect(self.loadFolder)
self.filenameEdit = QtGui.QLineEdit('filename')
self.name = os.path.join(self.folderEdit.text(),
self.filenameEdit.text())
# Snap button
self.snapButton = QtGui.QPushButton('Snap')
self.snapButton.setStyleSheet("font-size:16px")
self.snapButton.setSizePolicy(QtGui.QSizePolicy.Preferred,
QtGui.QSizePolicy.Expanding)
self.snapButton.setToolTip('Ctrl+S')
self.snapButton.clicked.connect(self.snap)
# REC button
self.recButton = QtGui.QPushButton('REC')
self.recButton.setStyleSheet("font-size:16px")
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
# Widgets
self.graph = MoleculesGraph(self)
self.enableBox = QtGui.QCheckBox('Enable')
self.enableBox.setEnabled(False)
self.enableBox.stateChanged.connect(self.graph.getTime)
self.lockButton = QtGui.QPushButton('Lock (no anda)')
self.lockButton.setCheckable(True)
self.lockButton.clicked.connect(self.toggleLock)
self.lockButton.setSizePolicy(QtGui.QSizePolicy.Preferred,
QtGui.QSizePolicy.Expanding)
self.alphaLabel = QtGui.QLabel('Alpha')
self.alphaLabel.setAlignment((QtCore.Qt.AlignRight |
QtCore.Qt.AlignVCenter))
self.alphaEdit = QtGui.QLineEdit('5')
self.alphaEdit.setFixedWidth(40)
# GUI layout
grid = QtGui.QGridLayout()
self.setLayout(grid)
grid.addWidget(self.graph, 0, 0, 1, 5)
grid.addWidget(self.enableBox, 1, 0)
grid.addWidget(self.alphaLabel, 1, 1)
self.editor = None
self.table = QtGui.QTableWidget()
self.table.setColumnCount(2)
self.table.horizontalHeader().hide()
self.table.verticalHeader().hide()
self.table.horizontalHeader().setStretchLastSection(True)
self.table.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
# self.table.horizontalHeader().setResizeMode(QtGui.QHeaderView.Interactive)
self.setRows(0)
buttonAdd = QtGui.QPushButton('Add')
buttonRemove = QtGui.QPushButton('Remove')
buttonEdit = QtGui.QPushButton('Edit')
buttonCopy = QtGui.QPushButton('Copy')
buttonActive = QtGui.QPushButton('Set Active')
buttonCopy.clicked.connect(self.copyFile)
buttonEdit.clicked.connect(self.editFile)
buttonActive.clicked.connect(self.setDefault)
buttonAdd.clicked.connect(self.addFile)
buttonRemove.clicked.connect(self.removeFile)
buttonL = QtGui.QGridLayout()
buttonL.addWidget(buttonAdd, 0, 0)
buttonL.addWidget(buttonRemove, 0, 1)
buttonL.addWidget(buttonEdit, 0, 2)
buttonL.addWidget(buttonCopy, 1, 0)
buttonL.addWidget(buttonActive, 1, 1, 1, 2)
# buttonL.addStretch()
def setText(self, text=None, temporary=False):
if text is None:
text = self.origText
#print text
QtGui.QPushButton.setText(self, text)
if not temporary:
self.origText = text
# Liveview functionality
self.liveviewButton = QtGui.QPushButton('LIVEVIEW')
self.liveviewButton.setStyleSheet("font-size:18px")
self.liveviewButton.setCheckable(True)
self.liveviewButton.setSizePolicy(QtGui.QSizePolicy.Preferred,
QtGui.QSizePolicy.Expanding)
self.liveviewButton.clicked.connect(self.liveview)
self.liveviewButton.setEnabled(False)
self.viewtimer = QtCore.QTimer()
self.viewtimer.timeout.connect(self.updateView)
# viewBox custom Tools
self.gridButton = QtGui.QPushButton('Grid')
self.gridButton.setCheckable(True)
self.gridButton.setEnabled(False)
self.crosshairButton = QtGui.QPushButton('Crosshair')
self.crosshairButton.setCheckable(True)
self.crosshairButton.setEnabled(False)
self.flipperButton = QtGui.QPushButton('x1000')
self.flipperButton.setStyleSheet("font-size:16px")
self.flipperButton.setCheckable(True)
self.flipperButton.clicked.connect(self.daq.toggleFlipper)
self.viewCtrl = QtGui.QWidget()
self.viewCtrlLayout = QtGui.QGridLayout()
self.viewCtrl.setLayout(self.viewCtrlLayout)
self.viewCtrlLayout.addWidget(self.liveviewButton, 0, 0, 1, 2)
self.viewCtrlLayout.addWidget(self.gridButton, 1, 0)
self.viewCtrlLayout.addWidget(self.crosshairButton, 1, 1)
self.viewCtrlLayout.addWidget(self.flipperButton, 2, 0, 1, 2)
def makeWidget(self):
l = self.makeLayout()
graphIcon = QtGui.QIcon()
graphIcon.addFile(':/images/wavelimits.png', state=QtGui.QIcon.On)
graphIcon.addFile(':/images/wavelimitsoff.png', state=QtGui.QIcon.Off)
self.graphBtn = QtGui.QPushButton()
self.graphBtn.setToolTip("Allows range selection by draging the interval boundaries on the graph")
self.graphBtn.setFixedWidth(20)
self.graphBtn.setFixedHeight(20)
self.graphBtn.setIcon(graphIcon)
self.graphBtn.setCheckable(True)
l.addWidget(QtGui.QLabel(" "))
l.addWidget(self.graphBtn)
l.addWidget(QtGui.QLabel(" "))
w = QWidgetWSignals()
w.setLayout(l)
w.setMinimumHeight(33)
w.sigChanged = w.sigValueChanged
w.sigChanging = w.sigValueChanging
def buildToolbox(self):
self.nodeToolbox = QtGui.QToolBox()
for section, nodes in library.getNodeTree().items():
tbwid = QtGui.QWidget()
tbl = QtGui.QGridLayout()
tbwid.setLayout(tbl)
row = 0
col = 0
for name in nodes:
itm = QtGui.QPushButton(name)
itm.clicked.connect(partial(self.nodeButtonPushed, name))
tbl.addWidget(itm, row, col)
col = col + 1
if col > 1:
row = row + 1
col = 0
#tbl.addStretch()
self.nodeToolbox.addItem(tbwid, section)
#self.nodeMenu.triggered.connect(self.nodeMenuTriggered)
self.nodeToolbox.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum)
return self.nodeToolbox
def addButton(label, widget=None, function=None):
button = QtGui.QPushButton(label)
if function is None:
button.clicked.connect(lambda: widget.setVisible(widget.isHidden()))
else:
button.clicked.connect(function)
button.setStyleSheet('QPushButton {'
'border-color: black;'
'border-width: 5px;}')
buttonBarWidgetLayout.addWidget(button)
return button
## first dock gets save/restore buttons
self.t = ParameterTree()
if params != None:
self.p_child = Parameter.create(name='params', type='group', children=params)
self.t.setParameters(self.p_child, showTop=False)
self.t.setWindowTitle('pyqtgraph example: Parameter Tree')
self.seq_cntr.addWidget(self.t)
self.seq = pg.LayoutWidget()
self.label = QtGui.QLabel("""Controls""")
self.saveBtn = QtGui.QPushButton('Add Action')
self.restoreBtn = QtGui.QPushButton('Modify table')
self.restoreBtn.setEnabled(False)
self.seq.addWidget(self.label, row=0, col=0)
self.seq.addWidget(self.saveBtn, row=1, col=0)
self.seq.addWidget(self.restoreBtn, row=2, col=0)
self.seq_cntr.addWidget(self.seq)
params = [
{'name': 'Basic opt. parameters', 'type': 'group', 'children': [
{'name': 'debug', 'type': 'bool', 'value': False},
{'name': 'logging', 'type': 'bool', 'value': True},
{'name': 'log file', 'type': 'str', 'value': 'test.log'},
{'name': 'timeout', 'type': 'float', 'value': 3, 'step': 0.1, 'limits': (0, 10)},
#{'name': 'SASE det.', 'type': 'list', 'values': {'mcp': 'mcp', 'gmd slow':'gmd_fl1_slow', 'bkr':'bkr', 'default':'gmd_default'}, 'value': "default"},
{'name': 'detector', 'type': 'list', 'values': ['gmd_default', 'mcp', 'gmd_fl1_slow', 'bkr'], 'value': "gmd_default"} ]}
]
self.t_cntr = ParameterTree()
self.p_cntr = Parameter.create(name='control', type='group', children=params)
self.t_cntr.setParameters(self.p_cntr, showTop=False)
self.restore_cur_btn = QtGui.QPushButton('Restore')
#self.restore_cur_btn.setEnabled(False)
self.setmax_opt_btn = QtGui.QPushButton('Set currents for max SASE')
#self.setmax_opt_btn.setEnabled(False)
self.stop_opt_btn = QtGui.QPushButton('Stop')
self.clear_disp_btn = QtGui.QPushButton('Clear display')
self.save_machine_btn = QtGui.QPushButton('Save new tuning')
#self.save_machine_btn.setEnabled(False)
#self.stop_btn = QtGui.QPushButton('stop')
#self.w5.addWidget(self.start_opt_btm, row=0, col=0)
self.w5.addWidget(self.stop_opt_btn, row=0, col=0)
self.w5.addWidget(self.restore_cur_btn, row=1, col=0)
#self.w5.addWidget(self.setmax_opt_btn, row=2, col=0)
self.w5.addWidget(self.clear_disp_btn, row=4, col=0)