Commit 3644de2a authored by Martin Drechsler's avatar Martin Drechsler

myParam added, where I build the gui with all the needed parameters for now

parent dd41c921
......@@ -5,20 +5,15 @@ Created on Thu May 31 14:22:48 2018
@author: Usuario
"""
from ADoutputs import daq_AO, daq_DO
#from ADoutputs import daq_AO, daq_DO
import pyqtgraph as pg
from pyqtgraph.Qt import QtCore, QtGui
from pyqtgraph.Qt import QtGui
#This creates the window for the gui
app = QtGui.QApplication([])
spins = [("Floating-point spin box, min=0, no maximum.", pg.SpinBox(value=5.0, bounds=[0, None]) )]
spin2 = ("Floating-point spin box, min=0, no maximum.", pg.SpinBox(value=5.0, bounds=[0, None]) )
win = QtGui.QMainWindow()
win.setWindowTitle('pyqtgraph example: SpinBox')
cw = QtGui.QWidget()
......@@ -27,6 +22,7 @@ cw.setLayout(layout)
win.setCentralWidget(cw)
win.show()
text = "Mi prueba fantastica"
spin = pg.SpinBox(value = 0.0, bounds=[-10, 10], step = .1)
......@@ -34,9 +30,9 @@ label = QtGui.QLabel(text)
layout.addWidget(label)
layout.addWidget(spin)
analog0 = daq_AO(0)
#analog0 = daq_AO(0)
def whenChange(sb):
analog0.set_analog_out(sb.value())
#def whenChange(sb):
# analog0.set_analog_out(sb.value())
spin.sigValueChanging.connect(whenChange)
\ No newline at end of file
#spin.sigValueChanging.connect(whenChange)
\ No newline at end of file
# -*- coding: utf-8 -*-
"""
This example demonstrates the use of pyqtgraph's parametertree system. This provides
a simple way to generate user interfaces that control sets of parameters. The example
demonstrates a variety of different parameter types (int, float, list, etc.)
as well as some customized parameter types
"""
import pyqtgraph as pg
from pyqtgraph.Qt import QtCore, QtGui
app = QtGui.QApplication([])
from pyqtgraph.parametertree import Parameter, ParameterTree, registerParameterType
params = [
{'name': '397 laser parameters', 'type': 'group', 'children': [
{'name': 'piezoA', 'type': 'float', 'value': 0, 'step': 0.05, 'limits': (-1, 1), 'siPrefix': True, 'suffix': 'V'},
{'name': 'piezoB', 'type': 'float', 'value': 0, 'step': 0.05, 'limits': (-1, 1), 'siPrefix': True, 'suffix': 'V'},
{'name': 'shutter1', 'type': 'bool', 'value': True, 'tip': "This is a checkbox"},
{'name': 'shutter2', 'type': 'bool', 'value': True, 'tip': "This is a checkbox"},
]},
{'name': '866 laser parameters', 'type': 'group', 'children': [
{'name': 'piezoA', 'type': 'float', 'value': 0, 'step': 0.05, 'limits': (-1, 1), 'siPrefix': True, 'suffix': 'V'},
{'name': 'piezoB', 'type': 'float', 'value': 0, 'step': 0.05, 'limits': (-1, 1), 'siPrefix': True, 'suffix': 'V'},
{'name': 'shutter1', 'type': 'bool', 'value': True, 'tip': "This is a checkbox"},
{'name': 'shutter2', 'type': 'bool', 'value': True, 'tip': "This is a checkbox"},
]},
{'name': '423 laser parameters', 'type': 'group', 'children': [
{'name': 'piezo', 'type': 'float', 'value': 0, 'step': 0.05, 'limits': (-1, 1), 'siPrefix': True, 'suffix': 'V'},
{'name': 'shutter1', 'type': 'bool', 'value': True, 'tip': "This is a checkbox"},
]},
{'name': 'Save/Restore functionality', 'type': 'group', 'children': [
{'name': 'Save State', 'type': 'action'},
{'name': 'Restore State', 'type': 'action', 'children': [
{'name': 'Add missing items', 'type': 'bool', 'value': True},
{'name': 'Remove extra items', 'type': 'bool', 'value': True},
]},
]},
]
## Create tree of Parameter objects
p = Parameter.create(name='params', type='group', children=params)
## If anything changes in the tree, print a message
def change(param, changes):
print("tree changes:")
for param, change, data in changes:
path = p.childPath(param)
if path is not None:
childName = '.'.join(path)
else:
childName = param.name()
print(' parameter: %s'% childName)
print(' change: %s'% change)
print(' data: %s'% str(data))
print(' ----------')
p.sigTreeStateChanged.connect(change)
def valueChanging(param, value):
print("Value changing (not finalized): %s %s" % (param, value))
def save():
global state
state = p.saveState()
def restore():
global state
add = p['Save/Restore functionality', 'Restore State', 'Add missing items']
rem = p['Save/Restore functionality', 'Restore State', 'Remove extra items']
p.restoreState(state, addChildren=add, removeChildren=rem)
p.param('Save/Restore functionality', 'Save State').sigActivated.connect(save)
p.param('Save/Restore functionality', 'Restore State').sigActivated.connect(restore)
## Create two ParameterTree widgets, both accessing the same data
t = ParameterTree()
t.setParameters(p, showTop=False)
t.setWindowTitle('pyqtgraph example: Parameter Tree')
win = QtGui.QWidget()
layout = QtGui.QGridLayout()
win.setLayout(layout)
layout.addWidget(QtGui.QLabel("These are two views of the same data. They should always display the same values."), 0, 0, 1, 2)
layout.addWidget(t, 1, 0, 1, 1)
win.show()
win.resize(800,800)
## test save/restore
s = p.saveState()
p.restoreState(s)
## Start Qt event loop unless running in interactive mode or using pyside.
if __name__ == '__main__':
import sys
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
QtGui.QApplication.instance().exec_()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment