def test_apply_rules(self): Builder = self.import_builder() Builder.load_string('<TLangClassCustom>:\n\tobj: 42') wid = TLangClass() Builder.apply(wid) self.assertIsNone(wid.obj) Builder.apply_rules(wid, 'TLangClassCustom') self.assertEqual(wid.obj, 42)
def initialize_display(self, stage_shape, selection_controller): """Sets :attr:`selection_controller` and generates and applies the kv GUI rules for the widget (``StageShapeDisplayStyle``). """ stage_shape.display = self self.stage_shape = stage_shape self.controller = self.selection_controller = selection_controller Builder.apply_rules( self, 'StageShapeDisplayStyle', dispatch_kv_post=True)
def apply_kv(self): super(FuncWidgetGroup, self).apply_kv() if self.ref_func is not None: return self.more = self.children_container = func_list = GroupFuncList() if self.show_more: self.add_widget(func_list) func_list.group_widget = self Builder.apply_rules( func_list, 'GroupFuncListStyle', dispatch_kv_post=True)
def create_settings_dropdown(self): """Creates the dropdown widget that displays the shape's configuration options. """ if self.settings_root is not None: return self.settings_root = Factory.FlatDropDown() self.settings_root.stage_shape = self.stage_shape Builder.apply_rules(self.settings_root, 'StageShapeDropdownStyle', dispatch_kv_post=True)
def on_views_layout(self, library_view, views_layout): rv = self.ids.rv if views_layout == 'grid': Builder.unbind_widget(rv.layout_manager.uid) Builder.apply_rules(rv.layout_manager, 'BookThumbViewContainer') rv.viewclass = BookThumbView rv.layout_manager.spacing = self.views_spacing elif views_layout == 'list': Builder.unbind_widget(rv.layout_manager.uid) Builder.apply_rules(rv.layout_manager, 'BookRowViewContainer') rv.viewclass = BookRowView rv.layout_manager.spacing = 0
def apply_kv(self): """Applies the kv rules to the widget. The rules are manually applied to the class because we want to have a chance to initialize some instance variables before the kv rules is applied so they can be referred to from kv without having to check if they are None. """ func = self.ref_func or self.func app = _get_app() func.fbind('on_changed', app.changed_callback) Builder.apply_rules(self, 'FuncWidgetStyle', dispatch_kv_post=True)
def apply_kv(self): """Applies the kv rules to the widget. The rules are manually applied to the class because we want to have a chance to initialize some instance variables before the kv rules is applied so they can be referred to from kv without having to check if they are None. """ app = _get_app() stage = self.ref_stage or self.stage stage.fbind('on_changed', app.changed_callback) Builder.apply_rules(self, 'StageWidgetStyle', dispatch_kv_post=True) more = self.more if self.ref_stage is not None: self.remove_widget(more) else: self.add_stage_containers(more)
def add_stage_containers(self, more_widget): """Adds the widget containers for the sub-stage, functions, and shapes widgets of this stage. :param more_widget: The widget to which the containers are added. This widget can be made invisible in the GUI. """ stage_widget = self.stage_widget = StageChildrenList() stage_widget.stage_widget = self stage_widget.drag_classes = ['stage'] stage_widget.drag_append_end = False stage_widget.back_color = (.482, .114, 0, 1) more_widget.add_widget(stage_widget) Builder.apply_rules(stage_widget, 'StageContainerListStyle', dispatch_kv_post=True) func_widget = self.func_widget = StageFuncChildrenList() func_widget.stage_widget = self func_widget.drag_classes = ['func', 'func_spinner'] func_widget.drag_append_end = False func_widget.back_color = (.196, .122, .063, 1) more_widget.add_widget(func_widget) Builder.apply_rules(func_widget, 'StageContainerListStyle', dispatch_kv_post=True) shape_widget = self.shape_widget = StageShapesChildrenList() shape_widget.stage_widget = self shape_widget.drag_classes = ['shape', 'shape_group'] shape_widget.drag_append_end = True shape_widget.back_color = (.835, .278, 0, 1) more_widget.add_widget(shape_widget) Builder.apply_rules(shape_widget, 'StageContainerListStyle', dispatch_kv_post=True) stage_widget.test_name = 'stage child list' func_widget.test_name = 'stage func list' shape_widget.test_name = 'stage shape list'