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)
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 main(): def create_filter(fn): regex = re.compile(fn, re.I) test = lambda p: regex.search(p) items.update_filter(test) with gui.Window() as w: with forms.NavForm() as nav: with forms.VerticalForm() as navbar: one = gui.Button() two = gui.Button() three = gui.Button() with forms.HeaderForm() as main: filter_field = QTextField() main_list = lists.VerticalList() items > bind() > main_list.collection items.bind.viewCount > bind() > three.bind.label items.bind.count > bind() > two.bind.label w.update_bindings() w.buffer = InputBuffer(w, create_filter) filter_field.textChanged += w.buffer.handle cmds.scriptJob(lj=True) return w
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 _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 __init__(self): with gui.Window(title="Example") as self.window: with forms.VerticalForm() as vf: self.thing = ExampleItem(self.settings) self.thing.field.update_bindings() poopy = gui.Button(label='print settings') poopy.command += self.query_settings self.window.show()
def __init__(self): with gui.Window(None, title="Example") as window: with forms.VerticalForm(None): self.thing1 = testItem(self.settings) self.thing1.field.proxy_update() gui.Button( 'poopy', label='print settings').command += self.query_settings cmds.showWindow(window)
def example_VerticalForm(): """ Example: import mGui.examples.formExamples as formExamples formExamples.example_VerticalForm() """ with gui.Window(None, title="Example", resizeToFitChildren=True) as window: with forms.VerticalForm(None, width=320) as main: for item in commands2: gui.Button(None, label=str(item['label'])).command += item['command'] cmds.showWindow(window)
def setUp(self): with gui.Window() as win: with forms.VerticalForm() as vf: btn = gui.Button() btn2 = gui.Button() for i in xrange(3): gui.Button() self._win = win self._vf = vf self._btn = btn self._btn2 = btn2
def example_VerticalForm(*args, **kwargs): """ Example: import mGui.examples.formExamples as formExamples formExamples.example_VerticalForm() """ with gui.Window(title="VerticalForm", resizeToFitChildren=True) as window: with forms.VerticalForm(width=320, margin=(12, 12)) as main: gui.ScrollField(text="Components stack vertically", ed=0, height=24) for label, command in COMMANDS: gui.Button(label=label).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()