本文整理汇总了Python中pyqtgraph.parametertree.ParameterTree.setParameters方法的典型用法代码示例。如果您正苦于以下问题:Python ParameterTree.setParameters方法的具体用法?Python ParameterTree.setParameters怎么用?Python ParameterTree.setParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqtgraph.parametertree.ParameterTree
的用法示例。
在下文中一共展示了ParameterTree.setParameters方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _draw_text_inputs
# 需要导入模块: from pyqtgraph.parametertree import ParameterTree [as 别名]
# 或者: from pyqtgraph.parametertree.ParameterTree import setParameters [as 别名]
def _draw_text_inputs(self, layout):
"""
Generates a GUI that can accept parameter values.
"""
params = [
{'name': 'damage :: Saturation Threshold', 'type': 'int',
'value': 10000, 'suffix': 'ADU'},
{'name': 'damage :: Area Threshold', 'type': 'int',
'value': 20, 'suffix': '%', 'limits': (0, 100)},
{'name': 'xtal :: Saturation Threshold', 'type': 'int',
'value': 5000, 'suffix': 'ADU'},
{'name': 'xtal :: Area Threshold', 'type': 'int',
'value': 1, 'suffix': '%', 'limits': (0, 100)},
{'name': 'diffuse :: Saturation Threshold', 'type': 'int',
'value': 1000, 'suffix': 'ADU'},
{'name': 'diffuse :: Area Threshold', 'type': 'int',
'value': 20, 'suffix': '%', 'limits': (0, 100)}
]
self._params = Parameter.create(name='params', type='group',
children=params)
self._params.sigTreeStateChanged.connect(self._enable_apply)
t = ParameterTree()
t.setParameters(self._params, showTop=False)
layout.addWidget(t, 0, 1)
return
示例2: Ui_ChildWindow
# 需要导入模块: from pyqtgraph.parametertree import ParameterTree [as 别名]
# 或者: from pyqtgraph.parametertree.ParameterTree import setParameters [as 别名]
class Ui_ChildWindow(object):
def setupUi(self, MainWindow, params):
#app = QtGui.QApplication([])
#self.win = QtGui.QMainWindow()
self.area = DockArea()
MainWindow.setCentralWidget(self.area)
MainWindow.resize(500, 700)
MainWindow.setWindowTitle('Action construct')
self.seq_cntr = Dock("Sequence", size=(150,200))
self.area.addDock(self.seq_cntr, 'left')
## first dock gets save/restore buttons
self.t = ParameterTree()
if params != None:
self.p_child = Parameter.create(name='params', type='group', children=params)
self.t.setParameters(self.p_child, showTop=False)
self.t.setWindowTitle('pyqtgraph example: Parameter Tree')
self.seq_cntr.addWidget(self.t)
self.seq = pg.LayoutWidget()
self.label = QtGui.QLabel("""Controls""")
self.saveBtn = QtGui.QPushButton('Add Action')
self.restoreBtn = QtGui.QPushButton('Modify table')
self.restoreBtn.setEnabled(False)
self.seq.addWidget(self.label, row=0, col=0)
self.seq.addWidget(self.saveBtn, row=1, col=0)
self.seq.addWidget(self.restoreBtn, row=2, col=0)
self.seq_cntr.addWidget(self.seq)
示例3: LayerControlTree
# 需要导入模块: from pyqtgraph.parametertree import ParameterTree [as 别名]
# 或者: from pyqtgraph.parametertree.ParameterTree import setParameters [as 别名]
class LayerControlTree(QtGui.QWidget):
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)
def addLayerControl(self,layer):
layerParam = setupLayerParam(layer.layerName(),layer.baseControlTemplate(),
layer.controlTemplate())
layerParam = self.paramGroup.addChild(layerParam)
# pass parameter to layer itself
layer.setLayerParameter(layerParam)
def removeLayerControl(self,layer):
paramToRemove = layer.layerParameter
self.paramGroup.removeChild(paramToRemove)
## If anything changes in the tree, print a message
def change(self,param, changes):
#print("tree changes:")
for param, change, data in changes:
path = self.paramGroup.childPath(param)
if path is not None:
childName = '.'.join(path)
else:
childName = param.name()
示例4: FringeRemoveNode
# 需要导入模块: from pyqtgraph.parametertree import ParameterTree [as 别名]
# 或者: from pyqtgraph.parametertree.ParameterTree import setParameters [as 别名]
class FringeRemoveNode(Node):
"""Node for removing fringes"""
nodeName = 'FringeRemove'
nodePaths = [('Analysis',)]
def __init__(self, name):
terminals = {
'sig':{'io':'in'},
'ref':{'io':'in'},
'bkg':{'io':'in'},
'sigMask': {'io':'in'},
'ref1':{'io':'out', 'bypass': 'ref'}
}
super().__init__(name, terminals=terminals)
paras_property = [
{'name': 'rank', 'type': 'int', 'readonly': True},
{'name': 'rankLimit', 'type': 'int', 'value': 100},
{'name': 'trunc', 'type': 'float'},
{'name': 'updateLib', 'type': 'bool'},
{'name': 'reset', 'type': 'action'}
]
self.paras = Parameter.create(name='params', type='group', children=paras_property)
self.paratree = ParameterTree()
self.paratree.setParameters(self.paras, showTop=False)
self.remover = FringeRemove()
self.paras.param('reset').sigActivated.connect(self.remover.reset)
def onReset(self):
self.remover.reset()
self.paras['rank'] = 0
def ctrlWidget(self):
return self.paratree
def process(self, sig, ref, bkg, sigMask, display=True):
self.remover.setTrunc(self.paras['trunc'])
ref = ref - bkg
if self.paras['updateLib'] and self.paras['rank'] <= self.paras['rankLimit']:
self.remover.updateLibrary(ref)
self.paras['rank'] = self.remover.rank
sig = sig - bkg
coef, ref = self.remover.reconstruct(np.ma.array(sig, mask=sigMask))
ref = ref.reshape(512, 512) + bkg
return {'ref1': ref}
def saveState(self):
state = super().saveState()
state['paras'] = self.paras.saveState()
return state
def restoreState(self, state):
super().restoreState(state)
self.paras.restoreState(state['paras'])
示例5: setupTree
# 需要导入模块: from pyqtgraph.parametertree import ParameterTree [as 别名]
# 或者: from pyqtgraph.parametertree.ParameterTree import setParameters [as 别名]
def setupTree():
params = [
{'name':'Update Time (s)', 'type':'float', 'value':1},
{'name':'std', 'type':'float', 'value':0},
{'name':'Save Figure', 'type':'action', 'visible':True}
]
p = Parameter.create(name = 'params', type = 'group', children = params)
t = ParameterTree()
t.setParameters(p, showTop = False)
return t,p
示例6: setupTree
# 需要导入模块: from pyqtgraph.parametertree import ParameterTree [as 别名]
# 或者: from pyqtgraph.parametertree.ParameterTree import setParameters [as 别名]
def setupTree():
params = [
{'name':'Update Time (s)', 'type':'float', 'value':1},
{'name':'Sample Name', 'type':'int', 'value':1},
{'name':'Counter', 'type':'int', 'value':0}
]
p = Parameter.create(name = 'params', type = 'group', children = params)
t = ParameterTree()
t.setParameters(p, showTop = False)
return t,p
示例7: InputCalibrationChannel
# 需要导入模块: from pyqtgraph.parametertree import ParameterTree [as 别名]
# 或者: from pyqtgraph.parametertree.ParameterTree import setParameters [as 别名]
class InputCalibrationChannel(SheetForm, SheetBase):
def __init__(self, config, channel, parent=None):
SheetBase.__init__(self, parent)
SheetForm.__init__(self)
self.config = config
self.channel = channel
self.settings = self.config.get("InputCalibration.{0}".format(channel), ChannelSettings())
self.myCalibration = None
self.treeWidget = None
def setupUi(self, callback, MainWindow):
SheetForm.setupUi(self, MainWindow)
self.calibrationsCombo.addItems( list(AnalogInputCalibration.AnalogInputCalibrationMap.keys()) )
self.calibrationsCombo.currentIndexChanged["QString"].connect( self.onCalibrationChanged )
self.callback = callback
if self.settings.calibration:
self.onCalibrationChanged(self.settings.calibration)
self.calibrationsCombo.setCurrentIndex(self.calibrationsCombo.findText(self.settings.calibration))
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 )
def saveConfig(self):
if self.myCalibration:
self.settings.parameters[self.settings.calibration] = self.myCalibration.parameters
self.config["InputCalibration.{0}".format(self.channel)] = self.settings
示例8: SettingsEditorDialog
# 需要导入模块: from pyqtgraph.parametertree import ParameterTree [as 别名]
# 或者: from pyqtgraph.parametertree.ParameterTree import setParameters [as 别名]
class SettingsEditorDialog(QtGui.QDialog):
def __init__(self,ndViewer, parent):
super(SettingsEditorDialog, self).__init__(parent)
self.resize(800,600)
self.ndViewer = ndViewer
self.layout = QtGui.QVBoxLayout()
self.setLayout(self.layout)
self.paramTree = ParameterTree()
self.paramTree.setParameters(self.ndViewer.options.p, showTop=False)
self.layout.addWidget(self.paramTree)
def keyPressEvent(self, event):
if event.key() == QtCore.Qt.Key_Escape:
self.hide()
event.accept()
else:
super(QtGui.QDialog, self).keyPressEvent(event)
示例9: InstrumentLoggingSelection
# 需要导入模块: from pyqtgraph.parametertree import ParameterTree [as 别名]
# 或者: from pyqtgraph.parametertree.ParameterTree import setParameters [as 别名]
class InstrumentLoggingSelection( SelectionUi ):
def __init__(self, config, classdict, instancename="ExternalParameterSelection.ParametersSequence", plotNames=None, parent=None, instrumentLoggingHandler=None ):
super(InstrumentLoggingSelection, self).__init__(config, dict(), classdict, instancename, parent)
self.instrumentLoggingHandler = instrumentLoggingHandler
self.current = None
def setupUi(self, MainWindow):
super(InstrumentLoggingSelection, self).setupUi(MainWindow)
self.loggingHandlerTreeWidget = ParameterTree(self.splitter)
self.loggingHandlerTreeWidget.setObjectName("loggingHandlerTreeWidget")
self.loggingHandlerTreeWidget.headerItem().setText(0, "1")
self.loggingHandlerTreeWidget.header().setVisible(False)
def onActiveInstrumentChanged(self, modelIndex, modelIndex2 ):
self.current = self.parameters.at(modelIndex.row()).name
super(InstrumentLoggingSelection, self).onActiveInstrumentChanged( modelIndex, modelIndex2 )
self.loggingHandlerTreeWidget.setParameters( self.instrumentLoggingHandler.parameter(self.current) )
def refreshParamTree(self):
if self.current is not None:
self.loggingHandlerTreeWidget.setParameters( self.instrumentLoggingHandler.parameter(self.current) )
示例10: __init__
# 需要导入模块: from pyqtgraph.parametertree import ParameterTree [as 别名]
# 或者: from pyqtgraph.parametertree.ParameterTree import setParameters [as 别名]
def __init__(self, parent=None):
"""
Constructor
@param parent reference to the parent widget
@type QWidget
"""
super(MainWindow, self).__init__(parent)
self.setupUi(self)
self.plotly_pyqt5 = Plotly_PyQt5()
'''手动调整窗口部件的大小,使之看着更美观'''
self.widget_parameter_tree.setMaximumWidth(300)
self.widget_parameter_tree.setMinimumWidth(200)
self.QWebEngineView_ProductVsHs300.setMinimumHeight(500)
self.tabWidget.setMinimumHeight(400)
'''显示parametertree,这里通过布局管理器来把ParameterTree间接地嵌套进Widget窗口里面'''
from mypyqtgraph import p
from pyqtgraph.parametertree import ParameterTree
t = ParameterTree()
t.setParameters(p, showTop=False)
t.setHeaderLabels(["参数", "数值"])
# t.setWindowTitle('pyqtgraph example: Parameter Tree')
layout = QtGui.QGridLayout()
self.widget_parameter_tree.setLayout(layout)
layout.addWidget(
QtGui.QLabel("千石资本-和聚光明1号资产管理计划基本信息"), 0, 0, 1, 1)
layout.addWidget(t)
'''显示绘图函数'''
self.QWebEngineView_ProductVsHs300.load(
QUrl.fromLocalFile(self.plotly_pyqt5.get_plotly_path_product_vs_hs300()))
self.QWebEngineView_LagestBack.load(QUrl.fromLocalFile(self.plotly_pyqt5.get_plotly_path_lagest_back()))
self.QWebEngineView_PeriodReturn.load(QUrl.fromLocalFile(self.plotly_pyqt5.get_plotly_path_period_return()))
self.QWebEngineview_MonthReturn.load(QUrl.fromLocalFile(self.plotly_pyqt5.get_plotly_path_month_return()))
示例11: setupTree
# 需要导入模块: from pyqtgraph.parametertree import ParameterTree [as 别名]
# 或者: from pyqtgraph.parametertree.ParameterTree import setParameters [as 别名]
def setupTree(startup):
params = [
{'name':'ChA', 'type':'int', 'value': startup['ChA']},
{'name':'BiasV_ChA', 'type':'float', 'value': startup['BiasV_ChA']},
{'name':'ChA Singles (cps)', 'type':'float', 'value': startup['ChA Singles (cps)']},
{'name':'ChB', 'type':'int', 'value':startup['ChB']},
{'name':'BiasV_ChB', 'type':'float', 'value':startup['BiasV_ChB']},
{'name':'ChB Singles (cps)', 'type':'float', 'value': startup['ChB Singles (cps)']},
{'name':'Min (s)', 'type':'float', 'value':startup['Min (s)']},
{'name':'Max (s)', 'type':'float', 'value':startup['Max (s)']},
{'name':'binSize', 'type':'int', 'value':startup['binSize']},
{'name':'Update Time (s)', 'type':'float', 'value' :startup['Update Time (s)']},
{'name':'Counter', 'type':'int', 'value':startup['Counter']},
{'name':'algorithm', 'type':'str', 'value':startup['algorithm']},
{'name':'Pause Histogram', 'type':'bool', 'value':startup['Pause Histogram']},
{'name':'Reset Histogram', 'type':'action', 'visible':startup['Reset Histogram']},
{'name':'Save Path', 'type':'str', 'value':startup['Save Path']},
{'name':'Save Figure', 'type':'action', 'visible':startup['Save Figure']},
{'name':'Save Data', 'type':'action', 'visible':startup['Save Data']}
]
p = Parameter.create(name = 'params', type = 'group', children = params)
t = ParameterTree()
t.setParameters(p, showTop = False)
return t,p
示例12: __init__
# 需要导入模块: from pyqtgraph.parametertree import ParameterTree [as 别名]
# 或者: from pyqtgraph.parametertree.ParameterTree import setParameters [as 别名]
def __init__(self):
#==========================================
super(GUIMainWindow, self).__init__()
# CHANGE HERE -------------------------------------------------
# -------------------------------------------------------------
area = DockArea()
self.setCentralWidget(area)
self.resize(1280, 800)
self.setWindowTitle('Demo: How to use HARP with Python')
## Create docks, place them into the window one at a time.
## Note that size arguments are only a suggestion; docks will still have to
## fill the entire dock area and obey the limits of their internal widgets.
d1 = Dock("Control", size=(300,200)) ## give this dock the minimum possible size
d2 = Dock("Description", size=(300,800))
d31 = Dock("INTRA frame - Prediction Units", size=(500,300))
d32 = Dock("INTER frame - Prediction Units", size=(500,300))
#d33 = Dock("Dock3 - Transform Units", size=(500,300))
d41 = Dock("Frame Difference ", size=(100,100))
d42 = Dock("Current Frame ", size=(100,100))
d51 = Dock("CU Depths", size=(200,100))
d52 = Dock("MVs X Component", size=(200,100))
d53 = Dock("MVs Y Component", size=(200,100))
area.addDock(d2, 'left') ## place d1 at left edge of dock area (it will fill the whole space since there are no other docks yet)
area.addDock(d1, 'bottom', d2) ## place d2 at right edge of dock area
area.addDock(d31, 'right')
area.addDock(d32, 'bottom', d31)
#area.addDock(d33, 'bottom', d32)
area.addDock(d41, 'right')
area.addDock(d51, 'bottom', d41)
area.addDock(d42, 'right', d41)
area.addDock(d52, 'right', d51)
area.addDock(d53, 'right', d52)
#==========================================
def dock_ImageItem(self, Dock):
#==========================================
pgGLWidget = pg.GraphicsLayoutWidget()
ViewBox = pgGLWidget.addViewBox(invertY = True)
#ViewBox.setBackgroundColor((255,255,255))
ViewBox.setAspectLocked(True)
pgImageItem = pg.ImageItem(border='w')
ViewBox.addItem(pgImageItem)
Dock.addWidget(pgGLWidget)
return pgImageItem
#==========================================
def dock_CurveItem(self, Dock, Title, LabelX, LabelY):
#==========================================
pgGWindow= pg.GraphicsLayoutWidget()
pgPlot = pgGWindow.addPlot(title=Title)
x =[0,0,0]
y = [0,0]
pgCurveItem = pg.PlotCurveItem(x, y, stepMode=True, fillLevel=0, brush=(0, 255, 0, 80))
pgPlot.addItem(pgCurveItem)
pgPlot.setLabel('bottom', LabelX)
pgPlot.setLabel('left', LabelY)
Dock.addWidget(pgGWindow)
return pgCurveItem
self.ImageItem_d2 = dock_ImageItem(self, d2)
self.ImageItem_d31 = dock_ImageItem(self, d31)
self.ImageItem_d32 = dock_ImageItem(self, d32)
self.ImageItem_d41 = dock_ImageItem(self, d41)
self.ImageItem_d42 = dock_ImageItem(self, d42)
self.CurveItem_d51 = dock_CurveItem(self, d51, "CU Depths", "CU Depth", "Number of Occurences")
self.CurveItem_d52 = dock_CurveItem(self, d52, "MVs X Component", "Magnitude", "Number of Occurences")
self.CurveItem_d53 = dock_CurveItem(self, d53, "MVs Y Component", "Magnitude", "Number of Occurences")
params = [
{'name': 'Basic settings', 'type': 'group', 'children':
[
{'name': 'QP', 'type': 'int', 'value': 30},
{'name': 'x265', 'type': 'bool', 'value': True},
{'name': 'Show CUs', 'type': 'bool', 'value': True},
{'name': 'Show PUs', 'type': 'bool', 'value': True},
{'name': 'Show Modes', 'type': 'bool', 'value': True},
]},
]
## Create tree of Parameter objects
p = Parameter.create(name='params', type='group', children=params, readonly=False, enabled=True)
t = ParameterTree()
t.setParameters(p, showTop=False)
t.setWindowTitle('pyqtgraph example: Parameter Tree')
self.p = p
d1.addWidget(t)
MyWorkThread = WorkThread(self)
MyWorkThread.start()
Description = readImg(ProjectDir + "/Various/Resources/Special/LMS_Demo.png")
#.........这里部分代码省略.........
示例13: MolViewer
# 需要导入模块: from pyqtgraph.parametertree import ParameterTree [as 别名]
# 或者: from pyqtgraph.parametertree.ParameterTree import setParameters [as 别名]
#.........这里部分代码省略.........
shader = 'shaded'
smooth = True
for atom in mol.atoms:
radius = atom.radius() * scale
pos = atom.r
md = gl.MeshData.sphere(rows=rows, cols=cols, radius=radius)
m = gl.GLMeshItem(meshdata=md, smooth=smooth, shader=shader)
colors = np.ones((md.faceCount(), 4), dtype=float)
rgb = atom.color()
colors[:, 0] = rgb[0] # r
colors[:, 1] = rgb[1] # g
colors[:, 2] = rgb[2] # b
colors[:, 3] = 1.0 # a
md.setFaceColors(colors)
m.translate(pos[0], pos[1], pos[2])
self.viewwidget.addItem(m)
def drawbonds(self, mol):
'''Draw the bonds.
:param molecule: The molecule for which to show the bonds.
:type molecule: molecule.Molecule
'''
rows = 16
cols = 16
shader = 'shaded'
smooth = True
bond_radius = [0.1, 0.1]
draw_edges = False
edge_color = (0, 0, 0, 1)
z = np.asarray([0, 0, 1])
for bond in mol.bonds():
vec = bond.p1 - bond.p2
angle = angle_between_vectors(vec, z) * 180 / np.pi
axis = np.cross(z, vec)
md = gl.MeshData.cylinder(rows=rows, cols=cols, radius=bond_radius, length=bond.length())
m = gl.GLMeshItem(meshdata=md, smooth=smooth, drawEdges=draw_edges, edgeColor=edge_color, shader=shader)
colors = np.ones((md.faceCount(), 4), dtype=float)
rgb = bond.atoms[0].color()
colors[:, 0] = rgb[0]
colors[:, 1] = rgb[1]
colors[:, 2] = rgb[2]
colors[:, 3] = 1.0
md.setFaceColors(colors)
m.rotate(angle, axis[0], axis[1], axis[2])
m.translate(bond.p2[0], bond.p2[1], bond.p2[2])
self.viewwidget.addItem(m)
def drawgrid(self):
'''Show a grid in x,y,z planes.'''
# gx = gl.GLGridItem()
# gx.rotate(90, 0, 1, 0)
# w.addItem(gx)
# gy = gl.GLGridItem()
# gy.rotate(90, 1, 0, 0)
# w.addItem(gy)
gz = gl.GLGridItem()
self.viewwidget.addItem(gz)
def clearview(self):
'''Removes all items from ViewWidget.'''
# Not all items are removed in one loop. Why?
while len(self.viewwidget.items) > 0:
for i in self.viewwidget.items:
self.viewwidget.removeItem(i)
def clear(self):
'''Clears the viewwidget and deletes the molecule.'''
self.clearview()
self.mol = None
def info(self):
'''Shows a info box with basic infoemation about the molecule.'''
if self.mol is None:
QtGui.QMessageBox.information(self, 'Information', 'No molecule loaded')
self.infotree = TreeWindow(parent=self, mol=self.mol)
self.infotree.show()
def showspectrum(self):
win = SpectrumWindow(self)
win.show()
def about(self):
dlg = AboutDialog(self)
dlg.exec_()
def setparameter(self, mol):
params = [
{'name': mol.name, 'type': 'group', 'children': [
{'name': 'File', 'type': 'str', 'value': mol.filename, 'readonly': True},
{'name': 'Formula', 'type': 'str', 'value': mol.stoichiometry(), 'readonly': True},
{'name': 'Mass', 'type': 'float', 'value': mol.mass(), 'readonly': True},
{'name': 'Electrons', 'type': 'int', 'value': mol.nel(), 'readonly': True},
{'name': 'Charge', 'type': 'float', 'value': mol.charge, 'readonly': True}]
}]
p = Parameter.create(name='Molecule', type='group', children=params)
self.parametertree.setParameters(p, showTop=True)
示例14: show
# 需要导入模块: from pyqtgraph.parametertree import ParameterTree [as 别名]
# 或者: from pyqtgraph.parametertree.ParameterTree import setParameters [as 别名]
def show():
"""
Show epydemic GUI application.
"""
## Always start by initializing Qt (only once per application)
app = QtGui.QApplication([])
## Define a top-level widget to hold everything
w = QtGui.QWidget()
params = [
{'name': 'beta', 'type': 'float', 'value': 1.4247},
{'name': 'gamma', 'type': 'float', 'value': 0.14286, 'step': 0.1},
{'name': 'TS', 'type': 'float', 'value': 0.1},
{'name': 'ND', 'type': 'float', 'value': 70},
{'name': 'S0', 'type': 'float', 'value': 1-1e-6},
{'name': 'I0', 'type': 'float', 'value': 1e-6},
]
## Create tree of Parameter objects
p = Parameter.create(name='params', type='group', children=params)
t = ParameterTree()
t.setParameters(p, showTop=False)
## Create a grid layout to manage the widgets size and position
layout = QtGui.QGridLayout()
w.setLayout(layout)
w.resize(1000,600)
## Create some widgets to be placed inside
btn = QtGui.QPushButton('&Play')
btn2 = QtGui.QPushButton('&Stop')
btn3 = QtGui.QPushButton('E&xit')
cw = pg.GraphicsLayoutWidget()
p1 = cw.addPlot(row=0, col=0, title="S")
p1.setLabel('left', "Ratio")
p1.setLabel('bottom', "Time", units='day')
p2 = cw.addPlot(row=1, col=0, title="I")
p2.setLabel('left', "Ratio")
p2.setLabel('bottom', "Time", units='day')
p3 = cw.addPlot(row=2, col=0, title="R")
p3.setLabel('left', "Ratio")
p3.setLabel('bottom', "Time", units='day')
def compute():
import scipy.integrate as spi
import numpy as np
beta=p['beta']
gamma=p['gamma']
TS=p['TS']
ND=p['ND']
S0=p['S0']
I0=p['I0']
INPUT = (S0, I0, 0.0)
def diff_eqs(INP,t):
'''The main set of equations'''
Y=np.zeros((3))
V = INP
Y[0] = - beta * V[0] * V[1]
Y[1] = beta * V[0] * V[1] - gamma * V[1]
Y[2] = gamma * V[1]
return Y # For odeint
t_start = 0.0; t_end = ND; t_inc = TS
t_range = np.arange(t_start, t_end+t_inc, t_inc)
RES = spi.odeint(diff_eqs,INPUT,t_range)
## Plot
p1.clear()
p2.clear()
p3.clear()
p1.plot(t_range, RES[:, 0])
p2.plot(t_range, RES[:, 1])
p3.plot(t_range, RES[:, 2])
btn.clicked.connect(compute)
## Add widgets to the layout in their proper positions
layout.addWidget(t, 0, 0) # list widget goes in bottom-left
layout.addWidget(btn, 1, 0) # button goes in upper-left
layout.addWidget(btn2, 2, 0) # button goes in upper-left
layout.addWidget(btn3, 3, 0) # button goes in upper-left
layout.addWidget(cw, 0, 1, 4, 1) # plot goes on right side, spanning 3 rows
## Display the widget as a new window
w.show()
## Start the Qt event loop
app.exec_()
示例15: ExploreDataFile
# 需要导入模块: from pyqtgraph.parametertree import ParameterTree [as 别名]
# 或者: from pyqtgraph.parametertree.ParameterTree import setParameters [as 别名]
class ExploreDataFile(QtGui.QWidget):
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)
def OpenDataFile(self):
print("Reanalyze= " + str(self.params["Reanalyze"]))
file_name = str(getOpenFileName(self, "Neuron Data", "", "HDF5 Files (*.hdf5 *.h5)"))
if file_name == "":
return
self.LoadData(file_name, reanalyze=self.params["Reanalyze"])
self.setWindowTitle("Experiment Control - Data Analysis & Visualization: " + file_name)
def LoadData(self, neuron_data_file_name, reanalyze=False):
if self.neuron_data is not None:
self.neuron_data.close()
self.neuron_data = NeuronData(neuron_data_file_name, reanalyze=reanalyze)
self.trial_list_tree.clear()
for experiment_name in self.neuron_data.experiment_list:
experiment_tree_item = QtGui.QTreeWidgetItem([experiment_name])
self.trial_list_tree.addTopLevelItem(experiment_tree_item)
experiment = self.neuron_data.experiment[experiment_name]
if len(experiment.protocol_list) > 0:
for protocol_name in experiment.protocol_list:
protocol_tree_item = QtGui.QTreeWidgetItem([protocol_name])
experiment_tree_item.addChild(protocol_tree_item)
protocol = experiment.protocol[protocol_name]
if len(protocol.trial_list) > 0:
for trial_name in protocol.trial_list:
trial_tree_item = QtGui.QTreeWidgetItem([trial_name])
protocol_tree_item.addChild(trial_tree_item)
else:
self.trial_list_tree.removeItemWidget(protocol_tree_item, 0)
else:
self.trial_list_tree.removeItemWidget(experiment_tree_item, 0)
self.trial_list_tree.itemClicked.connect(self.UpdatePlot)
def SavePlotData(self):
file_name = str(getSaveFileName(self, "Save Plot data", "", "CSV (*.csv)"))
if file_name == "":
return
x_range = self.plot_widget.getItem(0, 0).viewRange()[0]
t = np.linspace(0, len(arena_out) / 10000.0, num=len(arena_out), endpoint=False)
"""if self.data['type'] == "trial":
c = pyx.canvas.canvas()
if self.data['type'] == "protocol":
c = pyx.canvas.canvas()"""
def UpdatePlot(self, item, column):
if str(item.text(0)) in self.neuron_data.experiment_list:
return
self.plot_widget.clear()
if item.childCount() == 0:
trial_name = str(item.text(0))
protocol_name = str(item.parent().text(0))
experiment_name = str(item.parent().parent().text(0))
protocol = self.neuron_data.experiment[experiment_name].protocol[protocol_name]
membrane_potential, spike_position_list, antennal_movement = protocol.trial[trial_name].AnalyzeTrial()
self.data = {
"type": "trial",
"trial name": trial_name,
"membrane potential": membrane_potential,
"spike position list": spike_position_list,
"antennal movement": antennal_movement,
"arena out": protocol.arena_out,
}
PlotTrial(
trial_name,
membrane_potential,
spike_position_list,
antennal_movement,
#.........这里部分代码省略.........