I have a parameter tree in my application.
For that tree when we set following properties:
tree = ParameterTree()
tree.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
This actually enables multiple selection of nodes\items on the Parameter Tree. But in the UI when we perform below mentioned steps I can see an issue:
1. Select a node\item in tree.
2. Press and hold shift key.
3. Select another node\item in tree.
4. Release the shift key.
Notice that only first item on which we clicked and the next item we clicked appear to be selected.
Now as soon as I move my mouse over the items between the first and the last item that was clicked.. the UI updates itself to show the items between them as selected.
Or If the parameter tree just loses focus then also all the items start to appear as selected.
Any idea why this is happening or how this can be resolved.
I know that Parameter Tree inherits from QTreeWidget which in turn inherits from QTreeView. I have explored its other selection modes but nothing works for the UI.
I have a parameter tree in my application.
For that tree when we set following properties:
tree = ParameterTree()
tree.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
This actually enables multiple selection of nodes\items on the Parameter Tree. But in the UI when we perform below mentioned steps I can see an issue:
1. Select a node\item in tree.
2. Press and hold shift key.
3. Select another node\item in tree.
4. Release the shift key.Notice that only first item on which we clicked and the next item we clicked appear to be selected.
Now as soon as I move my mouse over the items between the first and the last item that was clicked.. the UI updates itself to show the items between them as selected.
Or If the parameter tree just loses focus then also all the items start to appear as selected.
Any idea why this is happening or how this can be resolved.
I know that Parameter Tree inherits from QTreeWidget which in turn inherits from QTreeView. I have explored its other selection modes but nothing works for the UI.
import pyqtgraph as pg
from pyqtgraph.Qt import QtCore, QtGui
from pyqtgraph.parametertree import Parameter, ParameterTree
app = pg.mkQApp()
#Defining parameters without value .. so that we don't get any undo arrow.
test = 'test'
params = [
{'name': 'Basic parameter data types', 'type': 'group', 'children': [
{'name': test, },
{'name': 'Float', },
{'name': 'String', },
{'name': 'List', },
]},
]
p = Parameter.create(name='params', type='group', children=params)
t = ParameterTree()
t.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
t.setParameters(p, showTop=False)
#t.setWindowTitle('pyqtgraph example: Parameter Tree')
#t2 = ParameterTree()
#t2.setParameters(p, showTop=False)
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)
#layout.addWidget(t2, 1, 1, 1, 1)
win.show()
win.resize(800,800)
app.exec_()
So only thing missing is when we dont give any value to the parameter item... this issue with multiseleciton is replicated. Let me know in case more information is required.
Also here is my system info:
sys.platform: win32
sys.version: 2.7.3 | 64-bit | (default, Aug 8 2013, 05:30:12) [MSC v.1500 64 bit (AMD64)]
qt bindings: PySide 1.1.1
pyqtgraph: 0.9.8; None
config:
{'antialias': False,
'background': (0, 0, 0),
'editorCommand': None,
'enableExperimental': False,
'exitCleanup': True,
'foreground': (150, 150, 150),
'leftButtonPan': True,
'useOpenGL': False,
'useWeave': True,
'weaveDebug': False}
import pyqtgraph as pg
from pyqtgraph.Qt import QtCore, QtGui
from pyqtgraph.parametertree import Parameter, ParameterTree
app = pg.mkQApp()
#Defining parameters without value .. so that we don't get any undo arrow.
test = 'test'
params = [
{'name': 'Basic parameter data types', 'type': 'group', 'children': [
{'name': test, 'type': 'str', 'value': ''},
{'name': 'Float', 'type': 'str', 'value': ''},
{'name': 'String', 'type': 'str', 'value': ''},
{'name': 'List', 'type': 'str', 'value': ''},
{'name': 'List2', 'type': 'str', 'value': ''},
{'name': 'List3', 'type': 'str', 'value': ''},
{'name': 'List4', 'type': 'str', 'value': ''},
{'name': 'List5', 'type': 'str', 'value': ''},
]},
]
p = Parameter.create(name='params', type='group', children=params)
t = ParameterTree()
t.setColumnCount(1)
t.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
t.setParameters(p, showTop=False)
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)
app.exec_()So I was able to resolve it by:
1. Adding value ans type column for the parameters being added to the tree.
2. t.setColumnCount(1): Setting the column count as 1 so that only one column is visible.
Though the above mentioned issue is resolve.. there is still one more issue with this version of code.
Try to do a Ctrl+A using keyboard .. notice that all the nodes are not selected. and as soon as the tree looses focus the nodes appear as selected. Simiar issue I was not able to replicate using Tree Widget.
Any suggestions !!
self.tree.parent().setFocus()
self.tree.setFocus()