Beispiel #1
0
    def __init__(self, collection):

        # this is the collection of stuff to manage
        self.Collection = observable.ViewCollection(*collection)

        with gui.BindingWindow(
                None, title='bound collection example') as self.window:
            with forms.VerticalExpandForm('main') as main:
                gui.Separator(None, style='none', height=12)
                gui.Text(None, label="Here's stuff in my list")
                gui.Separator(None, style='none', height=12)

                with forms.HorizontalStretchForm('filter') as flt:
                    gui.TextField('filtertext', width=480)
                    gui.Separator(None,
                                  horizontal=False,
                                  style='none',
                                  width=4)
                    with forms.HorizontalExpandForm('display',
                                                    width=32) as hmm:
                        gui.Text('shown').bind.label < bind(
                        ) < self.Collection.bind.ViewCount
                        gui.Text(None, '/')
                        gui.Text('total').bind.label < bind(
                        ) < self.Collection.bind.Count

                self.Collection > bind() > lists.VerticalList(
                    'itemList', itemTemplate=ExampleTemplate).Collection

        self.window.main.itemList.NewWidget += self.hook_widget_events
        flt.filtertext.enterCommand += self.update_filter
        self.KEEPALIVE = self
Beispiel #2
0
    def widget(self, item):
        with BindingContext() as bc:
            with forms.HorizontalExpandForm('root',
                                            parent=self.Parent,
                                            height=60) as root:
                with forms.VerticalExpandForm('cb', width=60) as cbf:
                    gui.CheckBox(
                        'enabled', label='', tag=item,
                        value=item.enabled).bind.value > bind() > (item,
                                                                   'enabled')
                    cbf.dock(cbf.enabled, left=20, top=10, bottom=40, right=5)
                with forms.FillForm('path', width=300):
                    with gui.ColumnLayout('x'):
                        gui.Text('displayName',
                                 font='boldLabelFont').bind.label < bind() < (
                                     item, 'name')
                        gui.Text('path', font='smallObliqueLabelFont'
                                 ).bind.label < bind() < (item, 'path')
                with gui.GridLayout('btns', width=140, numberOfColumns=2):
                    edit = gui.Button('edit', label='Edit', tag=item)
                    show = gui.Button('show', label='Show', tag=item)

        root.cb.enabled.changeCommand += self.update_status
        root.btns.show.command += self.show_item
        root.btns.edit.command += self.edit

        return lists.Templated(item,
                               root,
                               edit=edit.command,
                               show=show.command)
Beispiel #3
0
    def widget(self, item):
        with BindingContext() as bc:
            with forms.HorizontalExpandForm(height=60,
                                            margin=(12, 0),
                                            backgroundColor=(.2, .2,
                                                             .2)) as root:
                with forms.VerticalExpandForm(width=60) as cbf:
                    enabled = gui.CheckBox(label='',
                                           tag=item,
                                           value=item.enabled)
                    enabled.bind.value > bind() > (item, 'enabled')
                    cbf.dock(enabled, left=20, top=10, bottom=40, right=5)
                with forms.FillForm(width=300) as path:
                    with gui.ColumnLayout() as cl:
                        display_name = gui.Text(font='boldLabelFont')
                        display_name.bind.label < bind() < (item, 'name')
                        path = gui.Text(font='smallObliqueLabelFont')
                        path.bind.label < bind() < (item, 'path')
                with gui.GridLayout(width=200, numberOfColumns=2) as btns:
                    edit = gui.Button(label='Edit', tag=item)
                    show = gui.Button(label='Show', tag=item)
        enabled.changeCommand += self.update_status
        show.command += self.show_item
        edit.command += self.edit

        return lists.Templated(item,
                               root,
                               edit=edit.command,
                               show=show.command)
Beispiel #4
0
def example_HorizontalExpandForm():
    """
    Example:
    import mGui.examples.formExamples as formExamples
    formExamples.example_HorizontalExpandForm()
    """
    with gui.Window(None, title="Example") as window:
        with forms.HorizontalExpandForm(None, width=320) as main:
            for item in commands2:
                gui.Button(None, label=str(item['label'])).command += item['command']

    cmds.showWindow(window)
Beispiel #5
0
    def __init__(self, collection):

        # this is the collection of stuff to manage
        self.collection = observable.ViewCollection(*collection)

        with gui.BindingWindow(title='bound collection example',
                               height=512,
                               width=512) as self.window:
            with forms.VerticalExpandForm(margin=(16, ),
                                          spacing=(8, 12)) as main:
                gui.Text(label="Type a filter and [enter] to limit the list")

                with forms.HorizontalExpandForm(width=512, ) as flt:
                    filter_text = gui.TextField(width=400)
                    filter_text.alwaysInvokeEnterCommandOnReturn = True
                    gui.Separator(horizontal=False, style='none', width=4)
                    with forms.HorizontalExpandForm(width=100) as display:
                        gui.Text("showing")
                        shown = gui.Text(width=24)
                        shown.bind.label < bind(
                        ) < self.collection.bind.viewCount
                        gui.Text(label='/')
                        total = gui.Text(width=24)
                        total.bind.label < bind() < self.collection.bind.count

                with forms.HorizontalExpandForm() as labels:
                    gui.Separator(style=None, width=48)
                    gui.Text("item", width=256, align='center')
                    gui.Separator(style=None, width=16)
                    gui.Text("translation", width=128, align='center')
                    gui.Separator(style=None, width=16)

                item_list = lists.VerticalList(itemTemplate=ExampleTemplate)
                self.collection > bind() > item_list.collection

        item_list.onWidgetCreated += self.hook_widget_events
        filter_text.enterCommand += self.update_filter
        self.KEEPALIVE = self
Beispiel #6
0
 def widget(self, item):
     with forms.HorizontalExpandForm(
             'tmp_%i' % id(item),
             width=250,
     ) as root:
         gui.IconTextButton('delete',
                            style='iconAndTextHorizontal',
                            image='delete',
                            tag=item)
         with forms.VerticalForm('names'):
             gui.NameField(None, object=item, width=250)
         with forms.VerticalForm('xform'):
             gui.AttrFieldGrp('t', label='translate', attribute=item + ".t")
     return lists.Templated(item, root, request_delete=root.delete.command)
Beispiel #7
0
def example_HorizontalExpandForm(*args, **kwargs):
    """
    Example:
    import mGui.examples.formExamples as formExamples
    formExamples.example_HorizontalExpandForm()
    """
    with gui.Window(title="HorizontalExpandForm") as window:
        with forms.HorizontalExpandForm(margin=(12, 12)) as main:
            gui.Button(label="Items Stack Horizontally")

            for label, command in COMMANDS:
                gui.Button(label=label).command += command
            gui.ScrollField(text="Last item expands", ed=0, ww=1)

    window.show()
Beispiel #8
0
    def widget(self, item):
        with forms.HorizontalExpandForm(tag=item) as root:
            delete_button = gui.IconTextButton(width=48,
                                               style='iconOnly',
                                               image='deleteShader')
            name_field = gui.NameField(object=item, width=256)
            gui.Separator(style='none', width=16)

            tx = gui.FloatField(width=48, pre=2)
            ty = gui.FloatField(width=48, pre=2)
            tz = gui.FloatField(width=48, pre=2)
            gui.Separator(style='none', width=16)

            # using 'connectControl' here is a good alternative to binding
            cmds.connectControl(tx, item + ".tx")
            cmds.connectControl(ty, item + ".ty")
            cmds.connectControl(tz, item + ".tz")

        delete_button.tag = root
        return lists.Templated(item,
                               root,
                               request_delete=delete_button.command)