本文整理汇总了Python中pyqtgraph.parametertree.Parameter类的典型用法代码示例。如果您正苦于以下问题:Python Parameter类的具体用法?Python Parameter怎么用?Python Parameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Parameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onCalibrationChanged
def onCalibrationChanged(self, calibration):
calibration = str(calibration)
if self.myCalibration:
self.settings.parameters[self.settings.calibration] = self.myCalibration.parameters
self.myCalibration = AnalogInputCalibration.AnalogInputCalibrationMap[calibration]()
if calibration in self.settings.parameters:
self.myCalibration.parameters = self.settings.parameters[calibration]
if not self.treeWidget:
try:
self.param = Parameter.create(name='params', type='group', children=self.myCalibration.paramDef())
self.treeWidget = ParameterTree()
self.treeWidget.setParameters(self.param, showTop=False)
self.verticalLayout.insertWidget(2, self.treeWidget)
self.param.sigTreeStateChanged.connect(self.myCalibration.update, QtCore.Qt.UniqueConnection)
except (TypeError, AttributeError):
pass
else:
self.param = Parameter.create(name='params', type='group', children=self.myCalibration.paramDef())
self.treeWidget.setParameters(self.param, showTop=False)
try:
self.param.sigTreeStateChanged.connect(self.myCalibration.update, QtCore.Qt.UniqueConnection )
except TypeError:
pass # we want the connection to be unique
self.settings.calibration = calibration
self.callback( self.channel, self.myCalibration )
示例2: __init__
def __init__(self, **opts):
opts['type'] = 'bool'
opts['value'] = True
Parameter.__init__(self, **opts)
self.addChild({'name': 'A = 1/B', 'type': 'float', 'value': 7, 'suffix': 'Hz', 'siPrefix': True})
self.addChild({'name': 'B = 1/A', 'type': 'float', 'value': 1/7., 'suffix': 's', 'siPrefix': True})
self.a = self.param('A = 1/B')
self.b = self.param('B = 1/A')
self.a.sigValueChanged.connect(self.aChanged)
self.b.sigValueChanged.connect(self.bChanged)
示例3: ImageExporter
class ImageExporter(Exporter):
Name = "Image File (PNG, TIF, JPG, ...)"
def __init__(self, item):
Exporter.__init__(self, item)
tr = self.getTargetRect()
self.params = Parameter(name='params', type='group', children=[
{'name': 'width', 'type': 'int', 'value': tr.width(), 'limits': (0, None)},
{'name': 'height', 'type': 'int', 'value': tr.height(), 'limits': (0, None)},
{'name': 'antialias', 'type': 'bool', 'value': True},
{'name': 'background', 'type': 'color', 'value': (0,0,0,255)},
])
self.params.param('width').sigValueChanged.connect(self.widthChanged)
self.params.param('height').sigValueChanged.connect(self.heightChanged)
def widthChanged(self):
sr = self.getSourceRect()
ar = sr.height() / sr.width()
self.params.param('height').setValue(self.params['width'] * ar, blockSignal=self.heightChanged)
def heightChanged(self):
sr = self.getSourceRect()
ar = sr.width() / sr.height()
self.params.param('width').setValue(self.params['height'] * ar, blockSignal=self.widthChanged)
def parameters(self):
return self.params
def export(self, fileName=None):
if fileName is None:
filter = ["*."+str(f) for f in QtGui.QImageWriter.supportedImageFormats()]
preferred = ['*.png', '*.tif', '*.jpg']
for p in preferred[::-1]:
if p in filter:
filter.remove(p)
filter.insert(0, p)
self.fileSaveDialog(filter=filter)
return
targetRect = QtCore.QRect(0, 0, self.params['width'], self.params['height'])
sourceRect = self.getSourceRect()
#self.png = QtGui.QImage(targetRect.size(), QtGui.QImage.Format_ARGB32)
#self.png.fill(pyqtgraph.mkColor(self.params['background']))
bg = np.empty((self.params['width'], self.params['height'], 4), dtype=np.ubyte)
color = self.params['background']
bg[:,:,0] = color.blue()
bg[:,:,1] = color.green()
bg[:,:,2] = color.red()
bg[:,:,3] = color.alpha()
self.png = pg.makeQImage(bg, alpha=True)
painter = QtGui.QPainter(self.png)
try:
self.setExportMode(True, {'antialias': self.params['antialias'], 'background': self.params['background']})
self.getScene().render(painter, QtCore.QRectF(targetRect), sourceRect)
finally:
self.setExportMode(False)
self.png.save(fileName)
painter.end()
示例4: SVGExporter
class SVGExporter(Exporter):
Name = "Scalable Vector Graphics (SVG)"
allowCopy = True
def __init__(self, item):
Exporter.__init__(self, item)
#tr = self.getTargetRect()
self.params = Parameter(name='params', type='group', children=[
#{'name': 'width', 'type': 'float', 'value': tr.width(), 'limits': (0, None)},
#{'name': 'height', 'type': 'float', 'value': tr.height(), 'limits': (0, None)},
#{'name': 'viewbox clipping', 'type': 'bool', 'value': True},
#{'name': 'normalize coordinates', 'type': 'bool', 'value': True},
#{'name': 'normalize line width', 'type': 'bool', 'value': True},
])
#self.params.param('width').sigValueChanged.connect(self.widthChanged)
#self.params.param('height').sigValueChanged.connect(self.heightChanged)
def widthChanged(self):
sr = self.getSourceRect()
ar = sr.height() / sr.width()
self.params.param('height').setValue(self.params['width'] * ar, blockSignal=self.heightChanged)
def heightChanged(self):
sr = self.getSourceRect()
ar = sr.width() / sr.height()
self.params.param('width').setValue(self.params['height'] * ar, blockSignal=self.widthChanged)
def parameters(self):
return self.params
def export(self, fileName=None, toBytes=False, copy=False):
if toBytes is False and copy is False and fileName is None:
self.fileSaveDialog(filter="Scalable Vector Graphics (*.svg)")
return
## Qt's SVG generator is not complete. (notably, it lacks clipping)
## Instead, we will use Qt to generate SVG for each item independently,
## then manually reconstruct the entire document.
xml = generateSvg(self.item)
if toBytes:
return xml.encode('UTF-8')
elif copy:
md = QtCore.QMimeData()
md.setData('image/svg+xml', QtCore.QByteArray(xml.encode('UTF-8')))
QtGui.QApplication.clipboard().setMimeData(md)
else:
with open(fileName, 'wb') as fh:
fh.write(asUnicode(xml).encode('utf-8'))
示例5: __init__
def __init__(self):
super(ResultsPlotting, self).__init__()
self.override = None
#ResultsTable manages class
self.table = ResultsTable()
self.table.setKeyOverride(self.processKnownKey)
self.graphoutput = OutputVsTime()
self.GraphOutputDock = QDockWidget(self.graphoutput.name)
self.GraphOutputDock.setObjectName(self.graphoutput.name)
self.GraphOutputDock.setAllowedAreas(Qt.BottomDockWidgetArea | Qt.RightDockWidgetArea| Qt.LeftDockWidgetArea)
self.GraphOutputDock.setWidget(self.graphoutput)
self.graphoutput.setDock(self.GraphOutputDock)
self.graphoutput.setKeyOverride(self.processKnownKey)
self.pgegraph = PGEVsTrace()
self.PGEGraphDock = QDockWidget(self.pgegraph.name)
self.PGEGraphDock.setObjectName(self.pgegraph.name)
self.PGEGraphDock.setAllowedAreas(Qt.BottomDockWidgetArea | Qt.RightDockWidgetArea| Qt.LeftDockWidgetArea)
self.PGEGraphDock.setWidget(self.pgegraph)
self.pgegraph.setDock(self.PGEGraphDock)
self.pgegraph.setKeyOverride(self.processKnownKey)
self.saveresults = ResultsSave()
resultsParams = [{'name':'Knownkey Source', 'type':'list', 'values':{'Attack Module':'attack', 'GUI Override':'gui'},
'value':'attack', 'set':self.setKnownKeySrc},
{'name':'Override Key', 'type':'str', 'key':'knownkey', 'value':'', 'set':self.setKnownKeyStr, 'readonly':True},
{'name':'Save Raw Results', 'type':'bool', 'value':False, 'set':self.saveresults.setEnabled}
]
self.params = Parameter.create(name="General Parameters", type='group', children=resultsParams)
ExtendedParameter.setupExtended(self.params, self)
示例6: __init__
def __init__(self, showScriptParameter=None, CWMainWindow=None):
self.cwAdv = CWAdvTrigger()
paramSS = [
{'name':'Serial Settings', 'type':'group', 'children':[
{'name':'Baud', 'key':'baud', 'type':'int', 'limits':(100, 500000), 'value':38400, 'step':100, 'set':self.updateSampleRate},
{'name':'Start Bits', 'key':'startbits', 'type':'int', 'limits':(1, 10), 'value':1},
{'name':'Stop Bits', 'key':'stopbits', 'type':'int', 'limits':(1, 10), 'value':1},
{'name':'Parity', 'key':'parity', 'type':'list', 'values':['none', 'even'], 'value':'none'},
]},
# TODO: Need to confirm oversample rate stuff
{'name':'Oversample Rate', 'key':'osrate', 'type':'int', 'limits':(2, 5), 'value':3, 'set':self.updateSampleRate},
{'name':'Calculated Clkdiv', 'key':'calcclkdiv', 'type':'int', 'readonly':True},
{'name':'Calculated Error', 'key':'calcerror', 'type':'int', 'suffix':'%', 'readonly':True},
{'name':'Trigger Character', 'key':'trigpatt', 'type':'str', 'value':'""', 'set':self.setPattern},
{'name':'Binary Pattern', 'key':'binarypatt', 'type':'str', 'value':''},
{'name':'Reset Module', 'type':'action', 'action':self.reset},
{'name':'Advanced Settings', 'type':'group', 'children':[
{'name':'Threshold', 'key':'threshold', 'type':'int', 'value':1, 'limits':(1, 10), 'set':self.reset},
{'name':'Initial Bit Correction', 'key':'initialcorrect', 'type':'int', 'value':3, 'limits':(0, 10), 'set':self.reset},
]}
]
self.oa = None
self.params = Parameter.create(name='Digital Pattern Trigger Module', type='group', children=paramSS)
ExtendedParameter.setupExtended(self.params, self)
self.showScriptParameter = showScriptParameter
示例7: __init__
def __init__(self, dictFiltPara=None):
self.dictFiltPara = dictFiltPara
self.bandDict = {"bandpass": 0, "lowpass": 1, "highpass": 2}
self.filtDict = {'name': 'Filter', 'type': 'group', 'children': [
{'name': 'band', 'type': 'list', 'values': self.bandDict, 'value': 0},
{'name': 'order', 'type': 'int', 'value': 2},
{'name': 'lowFreq', 'type': 'float', 'value': 0.02, 'step': 0.1, 'suffix': ' Hz'},
{'name': 'highFreq', 'type': 'float', 'value': 2.0, 'step': 0.1, 'suffix': ' Hz'},
{'name': 'reversepass', 'type': 'bool', 'value': False, 'tip': "This is a checkbox"},
{'name': 'seis', 'type': 'list', 'values': {"Stack": 0, "Trace": 1}, 'value': 0},
{'name': 'apply', 'type': 'bool', 'value': False, 'tip': "This is a checkbox"},
{'name': 'Confirm_Filt_Parameters', 'type': 'action'},
]}
self.filtKeys = ['lowFreq', 'highFreq', 'order', 'apply', 'reversepass']
self.params = [
RadioParameter(name='Sort'),
self.filtDict,
]
## Create tree of Parameter objects
self.paraTree = Parameter.create(name='params', type='group', children=self.params)
self.paraTree.sigTreeStateChanged.connect(self.treeChanged)
self.paraSort = self.paraTree.children()[0]
self.paraFilt = self.paraTree.children()[1]
self.onStack = True
# get parameters for action:
self.getSortPara()
self.setFiltTree()
self.getFiltPara()
示例8: __init__
def __init__(self):
QtGui.QWidget.__init__(self)
self.neuron_data = None
self.setWindowTitle("Experiment Control - Data Analysis & Visualization")
self.layout = QtGui.QVBoxLayout()
self.layout.setContentsMargins(0, 0, 0, 0)
self.setLayout(self.layout)
self.splitter = QtGui.QSplitter()
self.splitter.setOrientation(QtCore.Qt.Horizontal)
self.splitter2 = QtGui.QSplitter()
self.splitter2.setOrientation(QtCore.Qt.Vertical)
self.layout.addWidget(self.splitter)
self.splitter.addWidget(self.splitter2)
self.plot_widget = pg.GraphicsLayoutWidget()
self.tree = ParameterTree(showHeader=False)
self.params = Parameter.create(
name="params",
type="group",
children=[
dict(name="Reanalyze", type="bool", value=False),
dict(name="Load", type="action"),
dict(name="GCFR-sigma (ms)", type="float", value=100.0, step=0.1, limits=[1, 5000]),
dict(name="Save", type="action"),
],
)
self.tree.setParameters(self.params, showTop=False)
# self.params.param('Save').sigActivated.connect(self.SavePlot)
self.params.param("Load").sigActivated.connect(self.OpenDataFile)
self.splitter2.addWidget(self.tree)
self.trial_list_tree = pg.TreeWidget(parent=self.splitter2)
self.splitter.addWidget(self.plot_widget)
self.trial_list_tree.setColumnCount(1)
示例9: setupParameters
def setupParameters(self):
ssParams = [{'name':'STK500.exe Path', 'type':'str', 'key':'stk500path', 'value':r'C:\Program Files (x86)\Atmel\AVR Tools\STK500\Stk500.exe'},
{'name':'AVR Part', 'type':'list', 'key':'part', 'values':['atmega328p'], 'value':'atmega328p'},
{'name':'Test Reset', 'type':'action', 'action':self.testReset}
]
self.params = Parameter.create(name='Reset AVR via STK500', type='group', children=ssParams)
ExtendedParameter.setupExtended(self.params, self)
示例10: __init__
def __init__(self, parameterView):
"""Constructor. Defines all default parameters."""
super(ParameterTreeWidget, self).__init__()
defaultParams = [
{'name': 'General', 'type': 'group', 'children': [
{'name': 'General Config File Path',
'type': 'str', 'value': "config.cfg"},
]},
{'name': 'Video', 'type': 'group', 'children': [
{'name': 'GStreamer Video Source', 'type': 'list', 'values': {"Test Source": "videotestsrc", "Webcam": "v4l2src", "network": "udp"}, 'value': "videotestsrc", 'children': [
{'name': 'Network Source IP',
'type': 'str', 'value': "127.0.0.1"},
]},
{'name': 'Video Frame Rate', 'type': 'float',
'value': 5e1, 'siPrefix': True, 'suffix': 'Hz'},
{'name': 'Video Output File', 'type': 'str', 'value': "outvideo.mp4"},
{'name': 'Video Output File Policy', 'type': 'list', 'values': {
"Overwrite": "overwrite", "Append": "append", "Enumerate": "enumerate"}, 'value': "overwrite"},
]},
{'name': 'Annotation', 'type': 'group', 'children': [
{'name': 'Data Sample Rate', 'type': 'float',
'value': 5e1, 'siPrefix': True, 'suffix': 'Hz'},
{'name': 'Concurrent Labels', 'type': 'bool', 'value': False},
{'name': 'Save Annotator Key Mapping',
'type': 'bool', 'value': True},
{'name': 'Annotator Key Mapping Save File',
'type': 'str', 'value': "keymap.cfg"},
{'name': 'Annotator Data Output Target', 'type': 'list', 'values': {
"File": "file", "Standard Output": "stdout"}, 'value': "file"},
{'name': 'Data Output Filename', 'type': 'str',
'value': "annotated_data.txt"},
]},
{'name': 'Plotting', 'type': 'group', 'children': [
{'name': 'Plotted Samples', 'type': 'int', 'value': 500},
{'name': 'Plotter Refresh Rate', 'type': 'float',
'value': 2e1, 'siPrefix': True, 'suffix': 'Hz'},
]},
]
# MORE PARAMS TO BE IMPLEMENTED
# - output video file path
# - overwrite / append / create new output video file
# - custom Gstreamer source string
self.p = Parameter.create(
name='params', type='group', children=defaultParams)
"""
def flatten(param):
items = []
for ch in param.children():
items.extend(flatten(ch).items())
items.extend({param.name() : param.value()}.items())
return dict(items)
"""
self.t = parameterView # use the ID of the promoted graphicsView
self.t.setParameters(self.p, showTop=False)
self.t.show()
示例11: set_paratree
def set_paratree(self):
global p, name
params = []
dicti = {'name': u'Settings', 'type': 'group', 'expanded': True}
kinder = []
for seti in sets:
kind = {'name':seti.get('Name')}
if seti.get('Typ') == None:
kind['type'] = 'str'
kind['value'] = seti.get('Value')
elif '[' in seti.get('Typ'):
kind['type'] = 'list'
kind['values']=self.__return_enum__(seti.get('Typ'))
kind['value'] = seti.get('Value')
else:
kind['type'] =seti.get('Typ')
kind['value'] = eval(seti.get('Value'))
kinder.append(kind)
dicti['children'] = kinder
inp_dict = {'name': 'Aktionen', 'type': 'group', 'children': [
{'name': 'Speichern', 'type': 'action'}
]}
params.append(dicti)
params.append(inp_dict)
self.p = Parameter.create(name='params', type='group', children=params)
self.p.param('Aktionen', 'Speichern').sigActivated.connect(self.save)
示例12: __init__
def __init__(self, parent = None, savedstate=None):
super(ProjectSettingsDialog, self).__init__(parent)
self.setWindowTitle("Application Settings")
layout = QtGui.QVBoxLayout(self)
self.initKeyParamMapping()
self._settings = Parameter.create(name='params', type='group', children=settings_params)
if savedstate:
self._settings.restoreState(savedstate)
# Holds settings keys that have changed by the user when the
# dialog is closed. Used to update any needed gui values..
self._updated_settings={}
self._settings.sigTreeStateChanged.connect(self.handleSettingChange)
self.initSettingsValues()
self.ptree = ParameterTree()
self.ptree.setParameters(self._settings, showTop=False)
self.ptree.setWindowTitle('MarkWrite Application Settings')
layout.addWidget(self.ptree)
self.ptree.adjustSize()
# OK and Cancel buttons
self.buttons = QtGui.QDialogButtonBox(
QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel,
QtCore.Qt.Horizontal, self)
layout.addWidget(self.buttons)
self.buttons.accepted.connect(self.accept)
self.buttons.rejected.connect(self.reject)
self.resize(500,700)
示例13: setupParameters
def setupParameters(self):
ssParams = [{'name':'Interface', 'type':'list', 'key':'target', 'values':['xmega (PDI)', 'avr (ISP)'], 'value':'xmega (PDI)'},
{'name':'Post-Reset Delay', 'type':'int', 'key':'toggledelay', 'limits':(0, 10E3), 'value':0, 'suffix':'mS'},
{'name':'Test Reset', 'type':'action', 'action':self.testReset}
]
self.params = Parameter.create(name='Reset AVR/XMEGA via CW-Lite', type='group', children=ssParams)
ExtendedParameter.setupExtended(self.params, self)
示例14: setupParameters
def setupParameters(self):
cpaalgos = {'Progressive':CPAProgressive,
'Simple':CPASimpleLoop}
#if CPACython is not None:
# cpaalgos['Progressive-Cython'] = CPACython.AttackCPA_Progressive
if CPAProgressive_CAccel is not None:
cpaalgos['Progressive-C Accel'] = CPAProgressive_CAccel
attackParams = [{'name':'CPA Algorithm', 'key':'CPA_algo', 'type':'list', 'values':cpaalgos, 'value':CPAProgressive, 'set':self.updateAlgorithm},
{'name':'Hardware Model', 'type':'group', 'children':[
{'name':'Crypto Algorithm', 'key':'hw_algo', 'type':'list', 'values':{'AES-128 (8-bit)':models_AES128_8bit}, 'value':'AES-128', 'set':self.updateScript},
{'name':'Leakage Model', 'key':'hw_leak', 'type':'list', 'values':models_AES128_8bit.leakagemodels, 'value':1, 'set':self.updateScript},
]},
#TODO: Should be called from the AES module to figure out # of bytes
{'name':'Attacked Bytes', 'type':'group', 'children':
self.getByteList()
},
]
self.params = Parameter.create(name='Attack', type='group', children=attackParams)
ExtendedParameter.setupExtended(self.params, self)
self.setAnalysisAlgorithm(CPAProgressive, None, None)
self.updateBytesVisible()
self.updateScript()
示例15: __init__
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.basicParam = {'name': 'Layer','expanded':False, 'type': 'group','autoIncrementName':True, 'children': [
{'name': 'LayerType', 'type': 'list', 'values': {"RGB": 0, "LAB": 1, "ChannelWise": 2}, 'value': 0},
{'name': 'Channel', 'type': 'int', 'value': 0,'limits':[0,2]},
{'name': 'Opacity', 'type': 'float', 'value': 0.0, 'step': 0.1,'limits':[0,1]},
{'name': 'Show', 'type': 'bool', 'value': True, 'tip': "Show / Hide this layer"},
{'name': 'HideOthers', 'type': 'action','tip':"Hide all other layers"},
{'name': 'Gradient', 'type': 'colormap'},
#{'name': 'Subgroup', 'type': 'group', 'children': [
# {'name': 'Sub-param 1', 'type': 'int', 'value': 10},
# {'name': 'Sub-param 2', 'type': 'float', 'value': 1.2e6},
#]},
#{'name': 'Text Parameter', 'type': 'text', 'value': 'Some text...'},
#{'name': 'Action Parameter', 'type': 'action'},
]}
params = []
self.paramGroup = Parameter.create(name='params', type='group', children=params)
self.paramGroup.sigTreeStateChanged.connect(self.change)
self.parameterTree = ParameterTree()
self.parameterTree.setParameters(self.paramGroup, showTop=False)
# add view box to graph view layout
self.hbox = QtGui.QHBoxLayout()
self.setLayout(self.hbox)
self.hbox.addWidget(self.parameterTree)