Skip to content

Conversation

@seb5g
Copy link
Contributor

@seb5g seb5g commented Oct 29, 2025

use class method to self define itself allowing the subclassing of Parameter object and creation of the subclass

My issue was that I had to reimplement getitem to override the default behaviour before calling super:

something like

class ParameterPatch(Parameter):

    def __getitem__(self, names: Union[str, tuple[str,]]):
        if names == 'multiaxes':
            names = 'controller'
        elif 'multiaxes' in names:
            names = list(names)
            names[names.index('multiaxes')] = 'controller'
            names = tuple(names)
        super().__getitem__(names)

but because Parameter are instanciated with the create method hardcoding the use of Parameter, it won't use the modified class. The current solution is to reimplement also the create method. The use of the classmethod decorator in this PR allow to not make this reimplementation

allowing the subclassing of Parameter object and creation of the subclass
@j9ac9k
Copy link
Member

j9ac9k commented Nov 15, 2025

Great change @seb5g !

@j9ac9k j9ac9k merged commit 4b64b25 into pyqtgraph:master Nov 15, 2025
36 checks passed
@seb5g seb5g deleted the feature/create_parameter_as_classmethod branch November 15, 2025 20:21
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

Successfully merging this pull request may close these issues.

2 participants