本文整理汇总了Python中pyqtgraph.parametertree.ParameterTree.addParameters方法的典型用法代码示例。如果您正苦于以下问题:Python ParameterTree.addParameters方法的具体用法?Python ParameterTree.addParameters怎么用?Python ParameterTree.addParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqtgraph.parametertree.ParameterTree
的用法示例。
在下文中一共展示了ParameterTree.addParameters方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addSettings
# 需要导入模块: from pyqtgraph.parametertree import ParameterTree [as 别名]
# 或者: from pyqtgraph.parametertree.ParameterTree import addParameters [as 别名]
def addSettings(self, param):
"""Adds a dockwidget designed to store a ParameterTree, also adds to 'Windows' menu"""
parameterTree = ParameterTree()
parameterTree.addParameters(param._PyQtGraphParameter)
dock = self.addDock(parameterTree, name=param.getName(), area=Qt.TopDockWidgetArea)
dock.setMaximumWidth(560)
return dock
示例2: maintest
# 需要导入模块: from pyqtgraph.parametertree import ParameterTree [as 别名]
# 或者: from pyqtgraph.parametertree.ParameterTree import addParameters [as 别名]
class maintest(Parameterized):
def __init__(self):
super(maintest, self).__init__()
self.values = {'module 1': module(1), 'module 2': module(2), 'module 3': module(3)}
self.module = self.values['module 2']
p = [
{'name': 'Module', 'type': 'list',
'values': self.values,
'set': self.setmodule,
'get': self.getmodule,
'childmode': "root",
'help': '%namehdr%Boatload of text is possible here. Can use markup too with external help window.'},
{'name': 'Rocks to Skips', 'type': 'int', 'value': 0, 'help': 'Another help example', 'helpwnd': None,
'linked': ['1/Rocks to Skips']},
{'name': '1/Rocks to Skips', 'type': 'float', 'help': 'Another help example', 'helpwnd': None,
'get': self.getLinked}
]
self.params = Parameter(name='Root', type='group', children=p).register()
self.params.init()
self.t = ParameterTree()
self.t.addParameters(self.params.getPyQtGraphParameter())
self.test = Parameter(name='Test', type='group')
self.test.addChildren([
{'name': 'baud', 'type': 'int', 'key': 'baud', 'limits': (500, 2000000), 'value': 38400}
])
self.params.append(self.test)
self.test.remove()
self.test.getChild("baud").setValue(500)
self.params.append(self.test)
self.t2 = ParameterTree()
self.params2 = Parameter(name='Root', type='group')
self.params.getChild("Module").stealDynamicParameters(self.params2)
self.t2.addParameters(self.params2._PyQtGraphParameter)
self.params.save("abcde.txt")
self.params.load("abcde.txt")
def printhelp(self, msg, obj):
print msg
def getmodule(self):
return self.module
@setupSetParam("Module")
def setmodule(self, module):
print "Changing Module"
self.module = module
def getLinked(self):
try:
return 1.0 / float(self.params.getChild('Rocks to Skips').getValue())
except:
return 0
示例3: SpectrumViewer
# 需要导入模块: from pyqtgraph.parametertree import ParameterTree [as 别名]
# 或者: from pyqtgraph.parametertree.ParameterTree import addParameters [as 别名]
#.........这里部分代码省略.........
spawn.setWindowTitle('Molviewer :: Spectrum main window (child)')
spawn.show()
def open(self):
'''Open a new spectrum using the file dialog.'''
filenames = QtGui.QFileDialog.getOpenFileNames(self, 'Open Files', '', '*.dx;; *.jdx')
if filenames:
for f in filenames:
spectrum = Spectrum(f)
self.addspectrum(spectrum)
def save(self):
pass
def saveimage(self):
pass
def draw(self, spectrum):
'''Draw a new spectrum.
:param spectrum: The spectrum to draw.
:type spectrum: spectrum.Spectrum
:param color: The color in which the spectrum is drawn.
'''
p = self.plotwidget.plot(spectrum.x, spectrum.y, pen=spectrum.color)
if p not in self.plots:
self.plots.append(p)
if spectrum.datatype.lower() == 'infrared spectrum':
# Plot higher wavenumbers to the left hand side
self.plotwidget.invertX(True)
self.plotwidget.setLabel('bottom', '1/cm')
else:
self.plotwidget.setLabel('bottom', spectrum.xunits)
def fullscreen(self):
'''Toggle full screen window.'''
if self.windowState() & QtCore.Qt.WindowFullScreen:
self.showNormal()
else:
self.showFullScreen()
def togglesidebar(self):
if self.parametertree.isVisible():
self.parametertree.hide()
else:
self.parametertree.show()
def addspectrum(self, spectrum):
'''Add a new spectrum.
:param spectrum: The new spectrum.
:type spectrum: spectrum.Spectrum
'''
self.spectra.append(spectrum)
ind = self.spectra.index(spectrum)
spectrum.color = spectrumcolors[ind]
params = [
{'name': spectrum.title, 'type': 'group', 'children': [
{'name': 'Number', 'type': 'int', 'value': self.spectra.index(spectrum)},
{'name': 'Color', 'type': 'color', 'value': spectrum.color},
{'name': 'Visible', 'type': 'bool', 'value': True},
{'name': 'Action Parameter', 'type': 'action'},
{'name': 'Spectrum', 'type': 'str', 'value': spectrum, 'visible': False}]
}]
p = Parameter.create(name='Files', type='group', children=params)
p.sigTreeStateChanged.connect(self.change)
self.parametertree.addParameters(p, showTop=False)
self.params.append(p)
self.draw(spectrum)
def removespectrum(self):
'''Remove a spectrum from display.'''
num, ok = QtGui.QInputDialog.getText(self, 'Remove a spectrum', 'Enter spectrum number:')
if ok and num:
num = int(num)
self.plotwidget.removeItem(self.plots[num])
self.plots.pop(num)
self.spectra.pop(num)
self.params.pop(num)
self.parametertree.clear()
for p in self.params:
self.parametertree.addParameters(p, showTop=False)
def change(self, param, changes):
for param, change, data in changes:
spec = param.parent().child('Spectrum').value()
index = self.spectra.index(spec)
if isinstance(param.value(), QtGui.QColor):
self.plots[index].setPen(param.value())
self.spectra[index].color = param.value()
if param.name() == 'Visible':
if data is False:
self.plots[index].clear()
elif data is True:
self.plots[index].setData(self.spectra[index].x, self.spectra[index].y)
示例4: TraceManagerImport
# 需要导入模块: from pyqtgraph.parametertree import ParameterTree [as 别名]
# 或者: from pyqtgraph.parametertree.ParameterTree import addParameters [as 别名]
class TraceManagerImport(QtFixes.QDialog):
def __init__(self, parent=None):
super(TraceManagerImport, self).__init__(parent)
layout = QVBoxLayout()
# Set dialog layout
self.setLayout(layout)
self.setWindowTitle("Add Existing Trace")
self.openCfg = QPushButton("Load .cfg File")
self.openCfg.clicked.connect(self.loadCfg)
layout.addWidget(self.openCfg)
self.modName = QComboBox()
self.modName.addItem("Select format for manual mode only...")
self.modName.addItem("ChipWhisperer/Native")
self.modName.addItem("DPAContestv3")
if TraceContainerMySQL is not None:
self.modName.addItem("MySQL", TraceContainerMySQL)
self.modName.currentIndexChanged.connect(self.traceTypeChanged)
layout.addWidget(self.modName)
self.paramTree = ParameterTree()
layout.addWidget(self.paramTree)
buts = QHBoxLayout()
cancel = QPushButton("Close")
cancel.clicked.connect(self.abort)
ok = QPushButton("Import")
ok.clicked.connect(self.accept)
buts.addWidget(ok)
buts.addWidget(cancel)
layout.addLayout(buts)
self.tmanager = None
def abort(self):
self.tmanager = None
self.reject()
def traceTypeChanged(self, newindx):
self.openCfg.setEnabled(False)
newTT = self.modName.itemData(newindx)
self.tmanagerParams = newTT.getParamsClass(openMode=True)
self.tmanager = newTT(self.tmanagerParams)
self.paramTree.clear()
self.paramTree.addParameters(self.tmanagerParams.getParams()._PyQtGraphParameter)
def getTrace(self):
return self.tmanager
def updateConfigData(self):
if self.tmanager is not None:
self.tmanager.updateConfigData()
def loadCfg(self, fname=None):
if fname is None:
fname, _ = QFileDialog.getOpenFileName(self, 'Open file', QSettings().value("trace_last_file"), '*.cfg')
if fname:
QSettings().setValue("trace_last_file", fname)
self.modName.setEnabled(False)
#Figure out what format this is in
tc = TraceContainerConfig(fname)
fmt = tc.attr("format")
#Generate a temp class for getting parameters from
fmtclass = chipwhisperer.common.traces.TraceContainerTypes.TraceContainerFormatList[fmt]
#Use temp class to finally initilize our "good" version
self.tmanager = fmtclass()
self.tmanager.config.loadTrace(fname)
self.tmanager.loadAllConfig()
self.paramTree.clear()
self.paramTree.addParameters(self.tmanager.getParams()._PyQtGraphParameter)