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