Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# logtree
self.logtree = QtWidgets.QTreeView()
self.logtree.setSelectionBehavior(
QtWidgets.QAbstractItemView.SelectRows)
self._treemodel = QtGui.QStandardItemModel()
self.logtree.setModel(self._treemodel)
# metatabs
self.meta_tabs = QtWidgets.QTabWidget()
self.meta_tabs.addTab(QtWidgets.QWidget(), 'metadata')
self.__debug = dict()
if isinstance(QtPlot, QWidget):
self.qplot = QtPlot()
else:
self.qplot = QtPlot(remote=False)
if isinstance(self.qplot, QWidget):
self.plotwindow = self.qplot
else:
self.plotwindow = self.qplot.win
topLayout = QtWidgets.QHBoxLayout()
self.filterbutton = QtWidgets.QPushButton()
self.filterbutton.setText('Filter data')
self.filtertext = QtWidgets.QLineEdit()
self.outCombo = QtWidgets.QComboBox()
topLayout.addWidget(self.text)
topLayout.addWidget(self.filterbutton)
topLayout.addWidget(self.filtertext)
self.dataset = None
self.text = QtWidgets.QLabel()
# logtree
self.logtree = QtWidgets.QTreeView()
self.logtree.setSelectionBehavior(
QtWidgets.QAbstractItemView.SelectRows)
self._treemodel = QtGui.QStandardItemModel()
self.logtree.setModel(self._treemodel)
# metatabs
self.meta_tabs = QtWidgets.QTabWidget()
self.meta_tabs.addTab(QtWidgets.QWidget(), 'metadata')
self.__debug = dict()
if isinstance(QtPlot, QWidget):
self.qplot = QtPlot()
else:
self.qplot = QtPlot(remote=False)
if isinstance(self.qplot, QWidget):
self.plotwindow = self.qplot
else:
self.plotwindow = self.qplot.win
topLayout = QtWidgets.QHBoxLayout()
self.filterbutton = QtWidgets.QPushButton()
self.filterbutton.setText('Filter data')
self.filtertext = QtWidgets.QLineEdit()
self.outCombo = QtWidgets.QComboBox()
topLayout.addWidget(self.text)
self.text = QtWidgets.QLabel()
# logtree
self.logtree = QtWidgets.QTreeView()
self.logtree.setSelectionBehavior(
QtWidgets.QAbstractItemView.SelectRows)
self._treemodel = QtGui.QStandardItemModel()
self.logtree.setModel(self._treemodel)
# metatabs
self.meta_tabs = QtWidgets.QTabWidget()
self.meta_tabs.addTab(QtWidgets.QWidget(), 'metadata')
self.__debug = dict()
if isinstance(QtPlot, QWidget):
self.qplot = QtPlot()
else:
self.qplot = QtPlot(remote=False)
if isinstance(self.qplot, QWidget):
self.plotwindow = self.qplot
else:
self.plotwindow = self.qplot.win
topLayout = QtWidgets.QHBoxLayout()
self.filterbutton = QtWidgets.QPushButton()
self.filterbutton.setText('Filter data')
self.filtertext = QtWidgets.QLineEdit()
self.outCombo = QtWidgets.QComboBox()
topLayout.addWidget(self.text)
topLayout.addWidget(self.filterbutton)
Returns:
plot (QtPlot): the plot showing the data
'''
if samplerate is None:
if station is None:
raise Exception('There is no station')
samplerate = 1 / station.awg.getattr('AWG_clock')
else:
samplerate = samplerate
horz_var = np.arange(0, len(wave_raw) * samplerate, samplerate)
x = DataArray(name='time(s)', label='time (s)',
preset_data=horz_var, is_setpoint=True)
y = DataArray(
label='sweep value (mV)', preset_data=wave_raw, set_arrays=(x,))
plot = QtPlot(x, y)
return plot
# %% Enhance the qcodes functionality
try:
from qtpy.QtCore import Qt
from qtpy import QtWidgets
from qcodes.plots.pyqtgraph import QtPlot
def _qtt_keyPressEvent(self, e):
''' Patch to add a callback to the QtPlot figure window '''
if e.key() == Qt.Key_P:
print('key P pressed: copy figure window to powerpoint')
qtt.utilities.tools.addPPTslide(fig=self)
super(QtPlot, self).keyPressEvent(e)
# update the keypress callback function
QtPlot.keyPressEvent = _qtt_keyPressEvent # type: ignore
except BaseException:
pass
# %% Enhance the qcodes functionality
try:
import pyqtgraph as pg
def _copyToClipboard(self):
''' Copy the current image to a the system clipboard '''
app = pg.mkQApp()
clipboard = app.clipboard()
clipboard.setPixmap(self.win.grab())
QtPlot.copyToClipboard = _copyToClipboard # type: ignore
except BaseException:
def _qtt_keyPressEvent(self, e):
''' Patch to add a callback to the QtPlot figure window '''
if e.key() == Qt.Key_P:
print('key P pressed: copy figure window to powerpoint')
qtt.utilities.tools.addPPTslide(fig=self)
super(QtPlot, self).keyPressEvent(e)
figtemp.save(fname)
p.end()
else:
figtemp = fig.lp.plotwin.grab()
figtemp.save(fname)
elif isinstance(fig, QtWidgets.QWidget):
# generic method
figtemp = fig.plotwin.grab()
figtemp.save(fname)
elif isinstance(fig, QtWidgets.QWidget):
try:
figtemp = QtGui.QPixmap.grabWidget(fig)
except BaseException:
figtemp = fig.grab()
figtemp.save(fname)
elif isinstance(fig, qcodes.plots.pyqtgraph.QtPlot):
fig.save(fname)
else:
if verbose:
raise TypeError('figure is of an unknown type %s' % (type(fig),))
top = 120
left, top, width, height = _ppt_determine_image_position(ppt, figsize, fname, verbose=1)
if verbose >= 2:
print('fname %s' % fname)
slide.Shapes.AddPicture(FileName=fname, LinkToFile=False,
SaveWithDocument=True, Left=left, Top=top, Width=width, Height=height)
if subtitle is not None:
# add subtitle
subtitlebox = slide.Shapes.AddTextbox(
QtPlot.keyPressEvent = _qtt_keyPressEvent # type: ignore
except BaseException:
pass
# %% Enhance the qcodes functionality
try:
import pyqtgraph as pg
def _copyToClipboard(self):
''' Copy the current image to a the system clipboard '''
app = pg.mkQApp()
clipboard = app.clipboard()
clipboard.setPixmap(self.win.grab())
QtPlot.copyToClipboard = _copyToClipboard # type: ignore
except BaseException:
pass
raise IndexError('The dataset contains less than two data arrays')
if customfig is None:
if isinstance(paramname, str):
if title is None:
parameter_name = dataset.default_parameter_name(paramname=paramname)
title = 'Parameter: %s' % parameter_name
temp_fig = QtPlot(dataset.default_parameter_array(
paramname=paramname), show_window=False)
else:
if title is None:
title = 'Parameter: %s' % (str(paramname),)
for idx, parameter_name in enumerate(paramname):
if idx == 0:
temp_fig = QtPlot(dataset.default_parameter_array(
paramname=parameter_name), show_window=False)
else:
temp_fig.add(dataset.default_parameter_array(
paramname=parameter_name))
else:
temp_fig = customfig
text = 'Dataset location: %s' % dataset.location
if notes is None:
try:
metastring = reshape_metadata(dataset,
printformat=printformat)
except Exception as ex:
metastring = 'Could not read metadata: %s' % str(ex)
notes = 'Dataset %s metadata:\n\n%s' % (dataset.location,