本文整理汇总了Python中pyqtgraph.parametertree.ParameterTree.clear方法的典型用法代码示例。如果您正苦于以下问题:Python ParameterTree.clear方法的具体用法?Python ParameterTree.clear怎么用?Python ParameterTree.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqtgraph.parametertree.ParameterTree
的用法示例。
在下文中一共展示了ParameterTree.clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SpectrumViewer
# 需要导入模块: from pyqtgraph.parametertree import ParameterTree [as 别名]
# 或者: from pyqtgraph.parametertree.ParameterTree import clear [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)
示例2: TraceManagerImport
# 需要导入模块: from pyqtgraph.parametertree import ParameterTree [as 别名]
# 或者: from pyqtgraph.parametertree.ParameterTree import clear [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)