Forum Archive

How to use custom attribures in pyui?

oraant

I have a view like this

class PathView (ui.View):
    def __init__(self, *arg, **kw):
        print(arg, kw)    # notice here!
        self.flex = 'WH'
        self.path = None
        self.paths = []
        self.action = None

And I made a pyui, use the custom view PathView, and put some custom attributes like this:

{"bc": "oooo" }

When I run the first script, it printed this:

() {}

Why?How should I use it?

JonB

Those are custom attributes not custom arguments. what happens is the view is created, with no input args:

 v=PathView()

then, arguments are set:

 v.width =....
 v.bc="oooo"

and so on.
if you need to take action based on the custom attributes, you need to have those as @property's, to implement a setter.