示例#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
示例#2
0
文件: simple.py 项目: alfsici/mGui
    def __init__(self):
        self.color = [0, 0, 0]

        # 2-digit formmating
        pretty = lambda x: '{0[0]:.2f} {0[1]:.2f} {0[2]:.2f}'.format(x)

        with stylesheets.CSS(gui.FloatSliderButtonGrp,
                             stylesheets.defaults(),
                             columnWidth3=(64, 96, 32),
                             minValue=0,
                             maxValue=1,
                             backgroundColor=(1, 1, 1)):
            with gui.BindingWindow(title='simple example',
                                   width=512) as self.window:
                with forms.HorizontalStretchForm(width=512) as main:
                    with forms.VerticalForm(width=256) as sliders:
                        red = gui.FloatSliderButtonGrp(label='red', tag=0)
                        green = gui.FloatSliderButtonGrp(label='green', tag=1)
                        blue = gui.FloatSliderButtonGrp(label='blue', tag=2)
                    with forms.FillForm(width=256) as swatch:
                        canvas = gui.Canvas()
                        canvas.bind.rgbValue < bind() < self.bind.color
                        display = gui.Text()
                        display.bind.label < bind(pretty) < self.bind.color

            for grp in sliders.controls:
                grp.changeCommand += self.update_color
                grp.buttonCommand += self.average
示例#3
0
文件: modMgr.py 项目: alfsici/mGui
    def _layout(self):
        with forms.LayoutDialogForm() as base:
            with BindingContext() as bc:
                with forms.VerticalThreePane(width=512,
                                             margin=(4, 4),
                                             spacing=(0, 8)) as main:
                    with forms.VerticalForm() as header:
                        gui.Text(label='Installed Modules')

                    with forms.FillForm() as body:
                        mod_list = lists.VerticalList(
                            itemTemplate=ModuleTemplate)
                        mod_list.collection < bind() < (self._manager.modules,
                                                        'values')
                        # binds the 'values' method of the ModuleManager's modules{} dictionary

                    with forms.HorizontalStretchForm() as footer:
                        cancel = gui.Button(label='Cancel')
                        cancel.command += self._cancel
                        gui.Separator(style=None)
                        save = gui.Button(label='Save')
                        save.command += self._save

        base.fill(main, 5)
        mod_list.update_bindings()
示例#4
0
def example_HorizontalStretchForm():
    """
    Example:
    import mGui.examples.formExamples as formExamples
    formExamples.example_HorizontalStretchForm()
    """
    with gui.Window(None, title="Example", height=400) as window:
        with forms.HorizontalStretchForm(None, width=320) as main:
            for item in commands2:
                gui.Button(None, label=str(item['label'])).command += item['command']

    cmds.showWindow(window)
示例#5
0
def example_HorizontalStretchForm(*args, **kwargs):
    """
    Example:
    import mGui.examples.formExamples as formExamples
    formExamples.example_HorizontalStretchForm()
    """
    with gui.Window(title="HorizontalStretchForm", height=64,
                    width=512) as window:
        with forms.HorizontalStretchForm(width=320, margin=(12, 12)) as main:
            gui.ScrollField(text="Components stretch horizontally",
                            ed=0,
                            ww=True,
                            width=64,
                            height=40)

            for label, command in COMMANDS:
                gui.Button(label=label, height=40).command += command

    window.show()
示例#6
0
文件: modMgr.py 项目: Narinyir/mGui
    def _layout(self):
        with forms.LayoutDialogForm('base') as base:
            with BindingContext() as bc:
                with forms.VerticalThreePane('root', width=512) as main:
                    with forms.VerticalForm('header'):
                        gui.Text('x', 'Installed modules')

                    with forms.FillForm('middle'):
                        mod_list = lists.VerticalList(
                            'xxx', itemTemplate=ModuleTemplate)
                        mod_list.Collection < bind() < (self.ModMgr.Modules,
                                                        'values')
                        # binds the 'values' method of the ModuleManager's Modules{} dictionary

                    with forms.HorizontalStretchForm('footer'):
                        gui.Button('Cancel',
                                   label='cancel').command += self._cancel
                        gui.Separator(None, style='none')
                        gui.Button('Save', label='save').command += self._save
        base.fill(main, 5)
        mod_list.update_bindings()
示例#7
0
def basic_list_binding():
    '''
    Illustrates the basics of binding to a list.  The collection 'bound' contains some strings, and we
    bind it to the VerticalList 'list_view'.

    Adding items to the collection automatically redraws the list with the new items. In this case they are
    drawn with buttons, but lists allow you to customize the appearance of items extensively.

    This example also illustrates how to use closures to capture inter-object references, and how to keep callback
    functions alive without creating a full class.
    '''

    with gui.BindingWindow(title='example window',
                           menuBar=True) as test_window:
        bound = ViewCollection('pPlane1', 'pCube2')
        with forms.VerticalThreePane() as main:
            header = gui.Text(
                label="List classes make it easy to manage collections")
            list_view = lists.VerticalList(synchronous=True)
            bound > bind() > list_view.collection
            with forms.HorizontalStretchForm() as buttons:
                more = gui.Button(label='Add another')
                close = gui.Button(label='close')

    # use closures to capture the UI names without a full class
    def close_window(*_, **__):
        cmds.deleteUI(test_window)

    def show_more(*_, **__):
        r = random.choice(
            ("pPlane", "pCube", "pSphere")) + str(random.randint(2, 20))
        bound.append(r)

    # bind the functions to the handlers
    close.command += close_window, test_window
    more.command += show_more, test_window

    return test_window