def example_Forms(*args, **kwargs): """ Example: import mGui.examples.formExamples as formExamples formExamples.example_Forms() """ # Defining these in here, because well, the functions don't exist yet. examples = [("FillForm", example_FillForm), ("FooterForm", example_FooterForm), ("HeaderForm", example_HeaderForm), ("HorizontalExpandForm", example_HorizontalExpandForm), ("HorizontalForm", example_HorizontalForm), ("HorizontalStretchForm", example_HorizontalStretchForm), ("HorizontalThreePane", example_HorizontalThreePane), ("VerticalExpandForm", example_VerticalExpandForm), ("VerticalForm", example_VerticalForm), ("VerticalStretchForm", example_VerticalStretchForm), ("VerticalThreePane", example_VerticalThreePane)] with gui.Window(title="Forms Examples", height=128) as window: with forms.FillForm(margin=(12, 12)): with forms.HeaderForm(width=320) as main: gui.ScrollField( height=80, text= """This example shows many of the different kinds of formlayout presets in mGui.forms. Click buttons to show examples, and resize the windows to see the behavior""", ww=True, ed=0) with forms.VerticalForm(spacing=(0, 4)): for example_name, example_command in examples: gui.Button( label=example_name).command += example_command window.show()
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
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)
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()
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)
def example_FillForm(): """ Example: import mGui.examples.formExamples as formExamples formExamples.example_HorizontalThreePane() """ with gui.Window(None, title="Example") as window: with forms.FillForm(None, width=320) as main: for item in commands2: gui.Button(None, label=str(item['label'])).command += item['command'] cmds.showWindow(window)
def example_FillForm(*args, **kwargs): """ Example: import mGui.examples.formExamples as formExamples formExamples.example_FillForm() """ with gui.Window(title="FillForm") as window: with forms.FillForm(width=320, margin=(12, 12)) as main: for label, command in COMMANDS: gui.Button(label="Expands to fill form").command += command window.show()
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()
def create_floating_shelf(): if core.MAYA_VERSION >= '2017': with gui.WorkspaceControl() as win: with forms.FillForm() as f: with gui.ShelfTabLayout() as shelf: shelf_loader.load_shelf(shelf_dict, shelf)