def __init__(self, **kwargs): # Before doing anything, ensure the windows exist. EventLoop.ensure_window() # Assign the default context of the widget creation. if not hasattr(self, '_context'): self._context = get_current_context() no_builder = '__no_builder' in kwargs if no_builder: del kwargs['__no_builder'] on_args = {k: v for k, v in kwargs.items() if k[:3] == 'on_'} for key in on_args: del kwargs[key] super(Widget, self).__init__(**kwargs) # Create the default canvas if it does not exist. if self.canvas is None: self.canvas = Canvas(opacity=self.opacity) # Apply all the styles. if not no_builder: Builder.apply(self, ignored_consts=self._kwargs_applied_init) # Bind all the events. if on_args: self.bind(**on_args)
def __init__(self, **kwargs): # Before doing anything, ensure the windows exist. EventLoop.ensure_window() # assign the default context of the widget creation if not hasattr(self, '_context'): self._context = get_current_context() super(Widget, self).__init__(**kwargs) # Create the default canvas if not exist if self.canvas is None: self.canvas = Canvas(opacity=self.opacity) # Apply all the styles if '__no_builder' not in kwargs: #current_root = Builder.idmap.get('root') #Builder.idmap['root'] = self Builder.apply(self) #if current_root is not None: # Builder.idmap['root'] = current_root #else: # Builder.idmap.pop('root') # Bind all the events for argument in kwargs: if argument[:3] == 'on_': self.bind(**{argument: kwargs[argument]})
def __init__(self, **kwargs): # Before doing anything, ensure the windows exist. EventLoop.ensure_window() # Register touch events self.register_event_type("on_touch_down") self.register_event_type("on_touch_move") self.register_event_type("on_touch_up") super(Widget, self).__init__(**kwargs) # Create the default canvas if not exist if self.canvas is None: self.canvas = Canvas(opacity=self.opacity) # Apply all the styles if "__no_builder" not in kwargs: # current_root = Builder.idmap.get('root') # Builder.idmap['root'] = self Builder.apply(self) # if current_root is not None: # Builder.idmap['root'] = current_root # else: # Builder.idmap.pop('root') # Bind all the events for argument in kwargs: if argument[:3] == "on_": self.bind(**{argument: kwargs[argument]})
def __init__(self, **kwargs): # Before doing anything, ensure the windows exist. EventLoop.ensure_window() # Register touch events self.register_event_type('on_touch_down') self.register_event_type('on_touch_move') self.register_event_type('on_touch_up') super(Widget, self).__init__(**kwargs) # Create the default canvas if not exist if self.canvas is None: self.canvas = Canvas(opacity=self.opacity) # Apply all the styles if '__no_builder' not in kwargs: #current_root = Builder.idmap.get('root') #Builder.idmap['root'] = self Builder.apply(self) #if current_root is not None: # Builder.idmap['root'] = current_root #else: # Builder.idmap.pop('root') # Bind all the events for argument in kwargs: if argument[:3] == 'on_': self.bind(**{argument: kwargs[argument]})
def __init__(self, **kwargs): super(Widget, self).__init__() # Register touch events self.register_event_type('on_touch_down') self.register_event_type('on_touch_move') self.register_event_type('on_touch_up') # Before doing anything, ensure the windows exist. EventLoop.ensure_window() # Auto bind on own handler if exist properties = self.__properties.keys() for func in dir(self): if not func.startswith('on_'): continue name = func[3:] if name in properties: self.bind(**{name: getattr(self, func)}) # Create the default canvas if not exist if self.canvas is None: self.canvas = Canvas() # Apply the existing arguments to our widget for key, value in kwargs.iteritems(): if hasattr(self, key): setattr(self, key, value) # Apply all the styles if '__no_builder' not in kwargs: Builder.apply(self)
def __init__(self, **kwargs): # Before doing anything, ensure the windows exist. EventLoop.ensure_window() # Assign the default context of the widget creation. if not hasattr(self, '_context'): self._context = get_current_context() no_builder = '__no_builder' in kwargs if no_builder: del kwargs['__no_builder'] on_args = {k: v for k, v in kwargs.items() if k[:3] == 'on_'} for key in on_args: del kwargs[key] super(Widget, self).__init__(**kwargs) # Create the default canvas if it does not exist. if self.canvas is None: self.canvas = Canvas(opacity=self.opacity) # Apply all the styles. if not no_builder: #current_root = Builder.idmap.get('root') #Builder.idmap['root'] = self Builder.apply(self) #if current_root is not None: # Builder.idmap['root'] = current_root #else: # Builder.idmap.pop('root') # Bind all the events. if on_args: self.bind(**on_args)
def __init__(self, **kwargs): # Before doing anything, ensure the windows exist. EventLoop.ensure_window() # Register touch events self.register_event_type('on_touch_down') self.register_event_type('on_touch_move') self.register_event_type('on_touch_up') super(Widget, self).__init__(**kwargs) # Create the default canvas if not exist if self.canvas is None: self.canvas = Canvas() # Apply all the styles if '__no_builder' not in kwargs: #current_root = Builder.idmap.get('root') #Builder.idmap['root'] = self Builder.apply(self) #if current_root is not None: # Builder.idmap['root'] = current_root #else: # Builder.idmap.pop('root') # Bind all the events for argument, value in kwargs.items(): if argument.startswith('on_'): self.bind(**{argument: value})
def __init__(self, **kwargs): # Before doing anything, ensure the windows exist. EventLoop.ensure_window() # Assign the default context of the widget creation. if not hasattr(self, '_context'): self._context = get_current_context() no_builder = '__no_builder' in kwargs self._disabled_value = False if no_builder: del kwargs['__no_builder'] on_args = {k: v for k, v in kwargs.items() if k[:3] == 'on_'} for key in on_args: del kwargs[key] self._disabled_count = 0 super(Widget, self).__init__(**kwargs) # Create the default canvas if it does not exist. if self.canvas is None: self.canvas = Canvas(opacity=self.opacity) # Apply all the styles. if not no_builder: Builder.apply(self, ignored_consts=self._kwargs_applied_init) # Bind all the events. if on_args: self.bind(**on_args)
def __init__(self, **kwargs): super(Widget, self).__init__() # Register touch events self.register_event_type('on_touch_down') self.register_event_type('on_touch_move') self.register_event_type('on_touch_up') # Before doing anything, ensure the windows exist. EventLoop.ensure_window() # Auto bind on own handler if exist properties = self.__properties.keys() for func in dir(self): if not func.startswith('on_'): continue name = func[3:] if name in properties: self.bind(**{name: getattr(self, func)}) # Create the default canvas self.canvas = Canvas() # Apply the existing arguments to our widget for key, value in kwargs.iteritems(): if hasattr(self, key): setattr(self, key, value) # Apply all the styles if '__no_builder' not in kwargs: Builder.apply(self)
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 test_apply_rules(self): Builder = self.import_builder() Builder.load_string('<TestClassCustom>:\n\tobj: 42') wid = TestClass() Builder.apply(wid) self.assertIsNone(wid.obj) Builder.apply_rules(wid, 'TestClassCustom') self.assertEqual(wid.obj, 42)
def __init__(self, **kwargs): builder = '__no_builder' not in kwargs kwargs.pop('__no_builder', None) super(MoaBase, self).__init__(**kwargs) if builder: Builder.apply(self) # Bind all the events. for argument in kwargs: if argument[:3] == 'on_': self.bind(**{argument: kwargs[argument]}) self.bind(knsname=self._verfiy_valid_name) self._verfiy_valid_name(self, self.knsname)
def __init__(self, **kwargs): # Before doing anything, ensure the windows exist. EventLoop.ensure_window() # Register touch events self.register_event_type('on_touch_down') self.register_event_type('on_touch_move') self.register_event_type('on_touch_up') super(Widget, self).__init__(**kwargs) # Create the default canvas if not exist if self.canvas is None: self.canvas = Canvas() # Apply all the styles if '__no_builder' not in kwargs: #current_root = Builder.idmap.get('root') #Builder.idmap['root'] = self Builder.apply(self)
def _process_last_build(cls): from kivy.lang import Builder #Get last rules imported for template creation k,r = Builder.rules[-1] p = r.ctx if not p.dynamic_classes: #Old school technique: get last rules from kivy.logger import Logger Logger.warn('Registering through old technique with .Klass:', k.key) t = BGTemplate() t.cls = (k.key,) Builder.apply(t) t.template_name = k.key else: kkey = p.dynamic_classes.keys()[0] t = Factory.get(kkey)() t.template_name = kkey #Now forcing id values to name for ID in t.ids: t.ids[ID].name = ID return t
def test_parser_numeric_2(self): Builder = self.import_builder() Builder.load_string('<TestClass>:\n\tobj: (0.5, 0.5, 0.5)') wid = TestClass() Builder.apply(wid) self.assertEqual(wid.obj, (0.5, 0.5, 0.5))