def __getattribute__(self, key): # print ">> Trying to get %s" % key if key in ("_model_attr", "__parent", "_model_class", "_model"): return object.__getattribute__(self, key) elif key in self._model_attr: # print " INTERCEPTED!" # Get the value of this key from the common data model val = getattr(self.__parent, key) # print " val or %s is %s" % (key, val) # Typecase as needed if isinstance(val, list): # Construct a list of property objects val2 = [] for a in val: # We have to create a whole new UI model for these... # class SubModel(UI_DataModel): # _model_class = type(a) # val2.append(SubModel(a)) val2.append(str(a)) else: val2 = str(val) # Invoke kivy's Property setter by setting our attribute setattr(self, key, val2) # Proceed as normal return EventDispatcher.__getattribute__(self, key) else: # print " Pushing up to base class" return EventDispatcher.__getattribute__(self, key)
def __init__(self, anim, widget): EventDispatcher.__init__(self) self.anim = anim self.widget = widget self.anim.bind(on_start=self._anim_started, on_progress=self._anim_progress, on_complete=self._anim_completed)
def __init__(self, **kwargs): BoxLayout.__init__(self, **kwargs) EventDispatcher.__init__(self, **kwargs) self.size_hint_y = None self.orientation = "horizontal" self.textInput = TextInput() self.textInput.size_hint_x = 0.9 self.textInput.multiline = False self.button = Button() self.button.text = "..." self.button.size_hint_min_x = 20 self.button.size_hint_x = None self.button.height = 25 self.button.width = 25 self.button.bind(width=self.set_button_width) self.add_widget(self.textInput) self.add_widget(self.button) self.register_event_type('on_value_changed') self.textInput.bind(on_text_validate=self.trigger_on_value_changed) self.height = 25
def __init__(self): EventDispatcher.__init__(self) self.register_event_type('on_uid') Thread.__init__(self) self.daemon = True self.q = deque() self.quit = False Clock.schedule_interval(self._poll_queue, 1 / 5.)
def __init__(self, *args, **kwargs): BetterLogger.__init__(self) self.log_deep_debug("Creating building with args", args, kwargs) self.on_building___type__(self, self.__type__) EventDispatcher.__init__(self, *args, **kwargs) SaveManager.register_update_game_data_function(self.update_game_data) if self.__type__ == "None": self.log_warning("BuildingBase needs to have a __type__, this should've be set when overridden")
def test_known_property_multiple_inheritance(): class Behavior: def __init__(self, name): print(f'Behavior: {self}, name={name}') super().__init__() class Widget2(Behavior, EventDispatcher): pass class Widget3(EventDispatcher, Behavior): pass with pytest.raises(TypeError) as cm: EventDispatcher(name='Pasta') assert "Properties ['name'] passed to __init__ may not be existing" \ in str(cm.value) Widget2(name='Pasta') # does not raise a ValueError Widget3(name='Pasta') # does not raise a ValueError
def __init__(self): BetterLogger.__init__(self) EventDispatcher.__init__(self) self.language_code = userSettings.get("UI", "language")
def __new__(cls, **kwargs): if cls.__instance is None: cls.__instance = EventDispatcher.__new__(cls) return cls.__instance
def __new__(cls, **kwargs): # XXX: Prevent Kivy Window from being a singleton return EventDispatcher.__new__(cls, **kwargs)
def __init__(self, tile, maze, **kwargs): MazeObject.__init__(self, tile=tile)#inherits from MazeObject EventDispatcher.__init__(self, **kwargs) self.orientation = 0 #0,1,2,3 = left,right,up,down self.maze = maze
def create_handler(self, window): import kivy from kivy.event import EventDispatcher handler = EventDispatcher() return handler
def __init__(self): EventDispatcher.__init__(self) BetterLogger.__init__(self, name="SaveManager")