Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter Lists : porting to 0.13.4 #2954

Open
pijyoi opened this issue Mar 8, 2024 · 0 comments
Open

Parameter Lists : porting to 0.13.4 #2954

pijyoi opened this issue Mar 8, 2024 · 0 comments

Comments

@pijyoi
Copy link
Contributor

pijyoi commented Mar 8, 2024

Documenting some behavior changes to Parameter list types since 0.13.4.

  1. Previously, it was possible to use values. Now limits must be used. (limits was added in 0.12.3)
  2. Previously, it was possible to not specify value, the first value from limits would be used. Now if you don't specify it, the first value from limits will still be used but sigTreeStateChanged gets fired upon instantiation.
import pyqtgraph as pg
import pyqtgraph.parametertree as ptree

## If anything changes in the tree, print a message
def change(param, changes):
    print("tree changes:")
    for param, change, data in changes:
        print('  parameter: %s'% param.name())
        print('  change:    %s'% change)
        print('  data:      %s'% str(data))
        print('  ----------')
    
params = [
    # on 0.13.3, all four of the following work and callback doesn't fire

    # first two no longer work since 0.13.4
    # callback fires upon instantiation
    {'name': 'List A', 'type': 'list', 'values': [1,2,3]},
    {'name': 'List B', 'type': 'list', 'values': [1,2,3], 'value': 1},
    # third one works on 0.13.4 but callback fires upon instantiation
    {'name': 'List C', 'type': 'list', 'limits': [1,2,3]},
    # fourth one works and doesn't fire a callback upon instantiation
    {'name': 'List D', 'type': 'list', 'limits': [1,2,3], 'value': 1},
]

pg.mkQApp()
p = ptree.Parameter.create(name='params', type='group', children=params)
p.sigTreeStateChanged.connect(change)
t = ptree.ParameterTree()
t.setParameters(p, showTop=False)
t.show()

# don't need to run event loop
# pg.exec()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant