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 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 __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 example_FooterForm(*args, **kwargs): """ Warning: If you give this layout less than one child there will be an error. Example: import mGui.examples.formExamples as formExamples formExamples.example_FooterForm() """ with gui.Window(title="FooterForm") as window: with forms.FooterForm(width=320, margin=(12, 12)) as main: gui.ScrollField(text="expandable top section") gui.Button(label='footer') window.show()
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)
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_VerticalStretchForm(): """ Example: import mGui.examples.formExamples as formExamples formExamples.example_VerticalStretchForm() """ with gui.Window(None, title="Example", height=400) as window: with forms.VerticalStretchForm(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 example_VerticalStretchForm(*args, **kwargs): """ Example: import mGui.examples.formExamples as formExamples formExamples.example_VerticalStretchForm() """ with gui.Window(title="VerticalStretchForm", height=400) as window: with forms.VerticalStretchForm(width=320, margin=(12, 12)) as main: gui.ScrollField(text="Components Stretch vertically", ed=0, height=24) for label, command in COMMANDS: gui.Button(label=label).command += command window.show()
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()
def example_HorizontalForm(*args, **kwargs): """ Example: import mGui.examples.formExamples as formExamples formExamples.example_HorizontalForm() """ with gui.Window(title="HorizontalForm", height=64, width=512) as window: with forms.HorizontalForm(width=320, margin=(12, 12)) as main: gui.ScrollField(text="Components stack horizontally", ed=0, width=128, ww=True) for label, command in COMMANDS: gui.Button(label=label, width=80).command += command window.show()
def example_HeaderForm(): """ Warning: If you give this layout less than one child there will be an error. Example: import mGui.examples.formExamples as formExamples formExamples.example_HorizontalThreePane() """ with gui.Window(None, title="Example") as window: with forms.HeaderForm(None, width=320) as main: i = 0 for item in commands2: i = i+1 if i > 2: break gui.Button(None, label=str(item['label'])).command += item['command'] cmds.showWindow(window)
def example_HorizontalThreePane(*args, **kwargs): """ Warning: If you give this layout less than three children there will be an error. Example: import mGui.examples.formExamples as formExamples formExamples.example_HorizontalThreePane() """ with gui.Window(title="HorizontalThreePane", height=64, width=512) as window: with forms.HorizontalThreePane(width=320, margin=(12, 12)) as main: gui.ScrollField(text="Fixed left pane", ed=0, width=128) for index, (label, command) in enumerate(COMMANDS): if index > 2: break gui.Button(label=label, width=32).command += command gui.ScrollField(text="Fixed right pane", ed=0, width=128) window.show()
def main(): with gui.Window(title="Ugly version") as main_window: with gui.ColumnLayout(width=256) as main: with gui.FrameLayout(label="buttons column") as t_buttons: with gui.ColumnLayout() as col: mk_sphere = gui.Button(label="Make Sphere") mk_cone = gui.Button(label="Make Cone") mk_cube = gui.Button(label="Make Cube") with gui.FrameLayout(label="buttons row") as r_buttons: with gui.RowLayout(numberOfColumns=3) as row: mk_sphere = gui.Button(label="Make Sphere") mk_cone = gui.Button(label="Make Cone") mk_cube = gui.Button(label="Make Cube") with gui.FrameLayout(label="buttons grid") as g_buttons: with gui.GridLayout(numberOfColumns=2) as grid: mk_sphere = gui.Button(label="Make Sphere") mk_cone = gui.Button(label="Make Cone") mk_cube = gui.Button(label="Make Cube") mk_circle = gui.Button(label="Make Circle") # using the iterability of the layout to set widths for item in main.t_buttons: item.width = 256 for item in main.r_buttons.row: item.width = 85 # last 'item' is the row itself... item.width = 256 item.columnWidth3 = (85, 85, 85) for item in main.g_buttons.grid: item.width = 128 # last item is the grid... item.width = 256 item.cellWidth = 128 return main_window
def example_VerticalThreePane(*args, **kwargs): """ Warning: If you give this layout less than three children there will be an error. Example: import mGui.examples.formExamples as formExamples formExamples.example_VerticalThreePane() """ with gui.Window(title="VerticalThreePane") as window: with forms.VerticalThreePane(None, width=320, height=320, margin=(12, 12)) as main: gui.ScrollField(text="Fixed Header, stretchy center", height=24, ed=False) for index, (label, command) in enumerate(COMMANDS): if index > 3: break gui.Button(label=label, height=24).command += command gui.ScrollField(text="Fixed footer", height=24, ed=0) window.show()
import mGui.gui as gui import maya.cmds as cmds """ This example shows a cleaned up version of traditional Maya GUI using context managers and addressing but no other new features Note: buttons are non-functional; this just shows layout style """ window = gui.Window('main window', title="Ugly version") with gui.ColumnLayout('gui', width=256) as main: with gui.FrameLayout("t_buttons", label="buttons column"): with gui.ColumnLayout("col"): gui.Button('mkSphere', label="Make Sphere") gui.Button('mkCone', label="Make Cone") gui.Button('mkCube', label="Make Cube") with gui.FrameLayout("r_buttons", label="buttons row"): with gui.RowLayout ("row", numberOfColumns=3): gui.Button('mkSphere', label="Make Sphere") gui.Button('mkCone', label="Make Cone") gui.Button('mkCube', label="Make Cube") with gui.FrameLayout("g_buttons", label="buttons grid"): with gui.GridLayout("grid", numberOfColumns=2): gui.Button('mkSphere', label="Make Sphere") gui.Button('mkCone', label="Make Cone") gui.Button('mkCube', label="Make Cube") gui.Button('mkCircle', label="Make Circle") # using the iterability of the layout to set widths
toppings = [ i.label for i in pizza.controls if isinstance(i, gui.CheckBoxMenuItem) and i.checkBox ] print "order pizza " + (" and ".join(toppings)) def radio_selected(*_, **kwargs): print 'delivery:', kwargs['sender'].label kwargs['sender'].parent.label = "Delivery: " + kwargs['sender'].label # the use of tag here acts as a keepalive, so the functions don't get garbage collected # this is a useful alternative to classes for simple cases with gui.Window(menuBar=True, tag=(food_selected, pizza_selected, radio_selected)) as test_window: with gui.Menu(label='TestMenu') as food_menu: # conventional menu items hotdog = gui.MenuItem(label='Hot Dog') burger = gui.MenuItem(label='Burger') taco = gui.MenuItem(label='Taco') for each in (hotdog, burger, taco): each.command += food_selected # a submenu with gui.SubMenu(label='Pizza') as sm: pepperoni = gui.CheckBoxMenuItem(label='Pepperoni') sausage = gui.CheckBoxMenuItem(label='Sausage') pineapples = gui.CheckBoxMenuItem(label='Pineapples')