theodox / mGui

Python module for cleaner maya GUI layout syntax
MIT License
123 stars 23 forks source link

Made OptionMenu bindable, using a similar API to TextScrollList. #33

Closed bob-white closed 8 years ago

theodox commented 8 years ago

What would you say to this instead?:

   @property
    def items(self):
        return [i.tag for i in self.controls]

    @items.setter
    def items(self, value):
        selected = self.select
        self.clear()
        self.controls[:] = [MenuItem(val, parent=self, tag=val) for val in value]
        if selected:
            self.select = selected

That way the collection remains the same. TextScrollList is a bit wierd because we know the collection has to be text. Going with the originals would means you get back MenuItem instances when you iterate over the colllection. What's the expected behavior there?

bob-white commented 8 years ago

That works for me.

So far my use case has been isolated to doing a one way binding of collection > menu. So I hadn't even noticed that a 2-way would mutate the collection's types and contents.

Updated the PR with your changes.