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
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 _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 _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 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
def __init__(self, collection): # this is the collection of stuff to manage self.collection = observable.ViewCollection(*collection) with gui.BindingWindow(title='bound collection example', height=512, width=512) as self.window: with forms.VerticalExpandForm(margin=(16, ), spacing=(8, 12)) as main: gui.Text(label="Type a filter and [enter] to limit the list") with forms.HorizontalExpandForm(width=512, ) as flt: filter_text = gui.TextField(width=400) filter_text.alwaysInvokeEnterCommandOnReturn = True gui.Separator(horizontal=False, style='none', width=4) with forms.HorizontalExpandForm(width=100) as display: gui.Text("showing") shown = gui.Text(width=24) shown.bind.label < bind( ) < self.collection.bind.viewCount gui.Text(label='/') total = gui.Text(width=24) total.bind.label < bind() < self.collection.bind.count with forms.HorizontalExpandForm() as labels: gui.Separator(style=None, width=48) gui.Text("item", width=256, align='center') gui.Separator(style=None, width=16) gui.Text("translation", width=128, align='center') gui.Separator(style=None, width=16) item_list = lists.VerticalList(itemTemplate=ExampleTemplate) self.collection > bind() > item_list.collection item_list.onWidgetCreated += self.hook_widget_events filter_text.enterCommand += self.update_filter self.KEEPALIVE = self
cr=True, horizontalScrollBarThickness=8, verticalScrollBarThickness=8) as cameraScrollLayout: with ColumnLayout("CameraCol", rs=10, adj=True, cal="left") as cameraLayout: Separator(h=10, st="none") with RowLayout(nc=3, adj=2): Text("New Camera name", al="left") newCameraField = TextField("NewCameraField", tx="", aie=True) addCameraButton = IconTextButton(i=iconsPath + "/add-video.png") cameraCollection = ViewCollection() cameraList = lists.VerticalList( synchronous=True, itemTemplate=CameraWidget) cameraCollection > bind() > cameraList.collection # with ColumnLayout("Render Settings", rs = 10, adj=1, cat=("both", 10)) as rsLayout: # Text("Export",fn="boldLabelFont") # #Mettre renderview # with RowLayout(nc=3, adj=2): # Text("Export path ", al="left") # TextField("ExportPath", en=False) # IconTextButton(i=":/browseFolder.png",c="SetExportPath('Set export path')") # with ColumnLayout(): # pass Separator(h=10, st="none") with RowLayout(nc=3, adj=2): Separator(w=100, st="in") renderButton = Button("Render",