def __init__(self, key=None, **kwargs): if key is None: for i in count(1): key = 'WorkspaceControl{!s}'.format(i) if not self.CMD(key, exists=True): break super(WorkspaceControl, self).__init__(key, **kwargs) self.bindingContext = BindingContext()
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 binding_context(self): """ createa BindingContext if needed """ if not hasattr(self, '_bind_ctx'): self._bind_ctx = BindingContext() return self._bind_ctx
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 _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()
class BindingWindow(Window): def __init__(self, key, *args, **kwargs): super(BindingWindow, self).__init__(key, *args, **kwargs) self.bindingContext = BindingContext() def __enter__(self): self.bindingContext.__enter__() return super(BindingWindow, self).__enter__() def __exit__(self, typ, value, traceback): super(BindingWindow, self). __exit__(typ, value, traceback) self.bindingContext.__exit__(None, None, None) def update_bindings(self): self.bindingContext.update(True)
class BindingWindow(Window): """ A Window with a built in BindingContext """ def __init__(self, key, *args, **kwargs): super(BindingWindow, self).__init__(key, *args, **kwargs) self.bindingContext = BindingContext() def __enter__(self): self.bindingContext.__enter__() return super(BindingWindow, self).__enter__() def __exit__(self, typ, value, traceback): super(BindingWindow, self).__exit__(typ, value, traceback) self.bindingContext.__exit__(None, None, None) def update_bindings(self): self.bindingContext.update(True)
class WorkspaceControl(Nested): '''Wrapper class for cmds.workspaceControl''' CMD = cmds.workspaceControl _ATTRIBS = [ 'restore', 'dockToPanel', 'tabPosition', 'initialHeight', 'widthProperty', 'requiredControl', 'close', 'tabToControl', 'floating', 'stateString', 'r', 'dockToMainWindow', 'uiScript', 'label', 'checksPlugins', 'initialWidth', 'minimumWidth', 'collapse', 'requiredPlugin', 'dockToControl', 'horizontal', 'heightProperty', 'loadImmediately', 'duplicatable' ] _CALLBACKS = ['initCallback'] def __init__(self, key=None, **kwargs): if key is None: for i in count(1): key = 'WorkspaceControl{!s}'.format(i) if not self.CMD(key, exists=True): break super(WorkspaceControl, self).__init__(key, **kwargs) self.bindingContext = BindingContext() def show(self): self.visible = True def hide(self): self.visible = False def __enter__(self): self.bindingContext.__enter__() return super(WorkspaceControl, self).__enter__() def __exit__(self, typ, value, traceback): self.bindingContext.__exit__(None, None, None) mGui_expand_stack = True super(WorkspaceControl, self).__exit__(typ, value, traceback) def update_bindings(self): self.bindingContext.update(True) def forget(self, *args, **kwargs): super(WorkspaceControl, self).forget() self.bindingContext = None
class WorkspaceControl(Nested): '''Wrapper class for cmds.workspaceControl''' CMD = cmds.workspaceControl _ATTRIBS = ['restore', 'dockToPanel', 'tabPosition', 'initialHeight', 'widthProperty', 'requiredControl', 'close', 'tabToControl', 'floating', 'stateString', 'r', 'dockToMainWindow', 'uiScript', 'label', 'checksPlugins', 'initialWidth', 'minimumWidth', 'collapse', 'requiredPlugin', 'dockToControl', 'horizontal', 'heightProperty', 'loadImmediately', 'duplicatable'] _CALLBACKS = ['initCallback'] def __init__(self, key=None, **kwargs): if key is None: for i in count(1): key = 'WorkspaceControl{!s}'.format(i) if not self.CMD(key, exists=True): break super(WorkspaceControl, self).__init__(key, **kwargs) self.bindingContext = BindingContext() def show(self): self.visible = True def hide(self): self.visible = False def __enter__(self): self.bindingContext.__enter__() return super(WorkspaceControl, self).__enter__() def __exit__(self, typ, value, traceback): self.bindingContext.__exit__(None, None, None) mGui_expand_stack = True super(WorkspaceControl, self).__exit__(typ, value, traceback) def update_bindings(self): self.bindingContext.update(True) def forget(self, *args, **kwargs): super(WorkspaceControl, self).forget() self.bindingContext = None
class BindingWindow(Window): """ A Window with a built in BindingContext """ def __init__(self, key=None, **kwargs): super(BindingWindow, self).__init__(key, **kwargs) self.bindingContext = BindingContext() def __enter__(self): self.bindingContext.__enter__() return super(BindingWindow, self).__enter__() def __exit__(self, typ, value, traceback): self.bindingContext.__exit__(None, None, None) mGui_expand_stack = True super(BindingWindow, self).__exit__(typ, value, traceback) def update_bindings(self): self.bindingContext.update(True) def forget(self, *args, **kwargs): super(BindingWindow, self).forget() self.bindingContext = None
def __init__(self, key, *args, **kwargs): super(BindingWindow, self).__init__(key, *args, **kwargs) self.bindingContext = BindingContext()
def __init__(self, key=None, **kwargs): super(BindingWindow, self).__init__(key, **kwargs) self.bindingContext = BindingContext()