• Clearly I need to explore the API modules more :)

  • Hmmm, I really think this is a nice update to what I posted here. I understand some may not think its good. Not sure.

    But by using the ViewWalker Class I posted the other day here

    And adding self.dict.update(ViewWalker(self).as_dict()) to the PYUIViewer class so you can access all your objects with dot notation rather than self['switch1'] for example.

    There is a limitation and that is your instance attrs and all your pyui objects have to have unique names. It's explained in the ViewWalker link. Hmmm, I am not sure it's really such a limitation. In a real app you would want this anyway.

    But if you load a pyui file in this manner and all your names are unique you have dot notation access to the objects as well as they are all accessible from the root level.

    I guess it would be nice to offer the same functionality (dot notation) in a hierarchical way instead of the flattened out way I am doing here.
    Hmmm, not sure I can figure that out just yet, @jonB, maybe that's something for you 😬😬
    Still nicer to do self.firstView.SecondView.ThirdView.switch1 = True
    Then ...
    self['firstView']...['switch1'].value = True

    I am not entirely sure why @omz didn't add this in somehow.

    Ok, I think it's exciting....maybe I am clapping with one hand 😱🎉🎉🎉🎉

    class PYUIViewer(ui.View): # this acts as a normal Custom ui.View class # the root view of the class is the pyui file read in def __init__(self, pyui_fn, *args, **kwargs): ui.load_view(pyui_fn, bindings={'MyClass': WrapInstance(self), 'self': self}) # call after so our kwargs modify attrs super().__init__(*args, **kwargs) # use the ViewWalker to get a dict of all the view controls/etc self.__dict__.update(ViewWalker(self).as_dict()) # i have a ui.Switch named switch1 in pyui file. # now i can refer to it directly, rather than use string # subscripts ie. self['switch1'] # but if could be self['v1']['sv1']['sv2']['switch1'] self['switch1'].value = False # conventional way self.switch1.value = False # after updating our dict
Internal error.

Oops! Looks like something went wrong!