def start_stage(self, stage_name, canvas): '''Starts the stage. It adds the graphics instructions to the canvas and starts playing the shapes. ''' from kivy.core.window import Window if self.tick_event: raise TypeError('Cannot start new stage while stage is active') Clock._max_fps = 0 self.tick_event = Clock.create_trigger(self.tick_callback, 0, interval=True) self.tick_delay_event = Clock.schedule_once(self.tick_event, .25) Window.fbind('on_flip', self.flip_callback) stage_factory: StageFactoryBase = _get_app().stage_factory stage = stage_factory.stage_names[last_experiment_stage_name] stage.pad_stage_ticks = 0 if self.output_count: msg = uuid.uuid4().bytes n = len(msg) data_serializer = App.get_running_app().data_serializer if self.pad_to_stage_handshake: stage.pad_stage_ticks = data_serializer.num_ticks_handshake(n) self.serializer = data_serializer.get_bits(-1, msg) self.current_canvas = canvas self.tick_func = stage_factory.tick_stage(last_experiment_stage_name) self._flip_stats['last_call_t'] = self._cpu_stats['last_call_t'] = \ self._cpu_stats['tstart'] = clock() self.add_graphics(canvas)
def on_show_label(self, *largs): '''Shows/hides the :attr:`pos_label` label. ''' state = self.show_label for shape in self.shapes: shape.widget.show_label = state label = self.pos_label if state: Window.add_widget(label) Window.fbind('mouse_pos', self._update_mouse_pos) self._update_mouse_pos(None, Window.mouse_pos) else: Window.remove_widget(label) Window.funbind('mouse_pos', self._update_mouse_pos)
def on_show_label(self, *largs): """Shows/hides the :attr:`pos_label` label depending on the value of :attr:`show_label`. """ state = self.show_label for shape in self.shapes: shape.widget.show_label = state label = self.pos_label if state: Window.add_widget(label) Window.fbind('mouse_pos', self._update_mouse_pos) self._update_mouse_pos(None, Window.mouse_pos) else: Window.remove_widget(label) Window.funbind('mouse_pos', self._update_mouse_pos)
async def run_app_async(cls_or_app, async_lib=None): """Entrance method used to start the App. It runs, or instantiates and runs a :class:`MoreKivyApp` type instance. """ from kivy.core.window import Window handler = _MoreKivyAppHandler() ExceptionManager.add_handler(handler) app = cls_or_app() if inspect.isclass(cls_or_app) else cls_or_app Window.fbind('on_request_close', app.ask_cannot_close) try: await app.async_run(async_lib=async_lib) except Exception as e: app.handle_exception(e, exc_info=sys.exc_info()) try: app.clean_up() except Exception as e: app.handle_exception(e, exc_info=sys.exc_info()) Window.funbind('on_request_close', app.ask_cannot_close) ExceptionManager.remove_handler(handler)
def __init__(self, **kwargs): super(IntentionsInterface, self).__init__(**kwargs) grid_size = 16 self.kernel = KernelBrainCemisid() self.biology_input = SetInternalVariableWidget('icons/biology.png', size_hint_y=0.33) self.culture_input = SetInternalVariableWidget('icons/culture.png', size_hint_y=0.33) self.feelings_input = SetInternalVariableWidget('icons/feelings.png', size_hint_y=0.33) self.internal_state_biology = ShowInternalVariableWidget( size_hint_y=0.33) self.internal_state_culture = ShowInternalVariableWidget( size_hint_y=0.33) self.internal_state_feelings = ShowInternalVariableWidget( size_hint_y=0.33) self.desired_biology_input = SetInternalVariableWidget( 'icons/biology.png', size_hint_y=0.33) self.desired_culture_input = SetInternalVariableWidget( 'icons/culture.png', size_hint_y=0.33) self.desired_feelings_input = SetInternalVariableWidget( 'icons/feelings.png', size_hint_y=0.33) # Main layout number of columns self.rows = 2 self.load_icons() self.declare_thinking_panel() self.declare_painters(grid_size) self.declare_inputs() self.declare_buttons() self.add_widgets_layouts() # Set windows size Window.size = (1127, 700) # Clear painters when window draw self.win_show_uid = Window.fbind('on_draw', self.clear) self.win_format_back_uid = Window.fbind('on_draw', self.format_backgrounds)
def start_stage(self, stage_name, canvas): '''Starts the stage. It adds the graphics instructions to the canvas and starts playing the shapes. ''' if self.tick_event: raise TypeError('Cannot start new stage while stage is active') Clock._max_fps = 0 self.tick_event = Clock.create_trigger( self.tick_callback, 0, interval=True) self.tick_delay_event = Clock.schedule_once(self.tick_event, .25) Window.fbind('on_flip', self.flip_callback) self.current_canvas = canvas self.tick_func = _get_app().stage_factory.tick_stage(stage_name) self._flip_stats['last_call_t'] = self._cpu_stats['last_call_t'] = \ self._cpu_stats['tstart'] = clock() if self.output_count: self.serializer = App.get_running_app().data_serializer.get_bits( -1, uuid.uuid4().bytes) self.add_graphics(canvas)
def __init__(self, **kwargs): super(BrainInterface, self).__init__(**kwargs) grid_size = 16 self.kernel = KernelBrainCemisid() # Main layout number of columns self.rows = 2 self.load_icons() self.declare_thinking_panel() self.declare_painters(grid_size) self.declare_inputs() self.declare_buttons() self.add_widgets_layouts() # Clear painters when window draw self.win_show_uid = Window.fbind('on_draw', self.clear)
def __init__(self, **kwargs): self._with_stencilbuffer = False super(FormulaGraph, self).__init__(**kwargs) from kivy.core.window import Window Window.fbind('mouse_pos', self._update_mouse_pos)
def __init__(self, *args, **kwargs): Window.fbind("mouse_pos", self.on_mouse_pos) super(ToolTipLabel, self).__init__(*args, **kwargs) self.tooltip = None self.trigger_tp = Clock.create_trigger(self.display_tooltip)
def init_class(): Window.fbind('mouse_pos', HighightButtonBehavior.track_mouse) HighightButtonBehavior.label = FollowingLabel(markup=True)
def show_menu_settings(self): menu = self.create_menu_settings() Window.fbind("on_resize", self.on_resize_menu_settings, menu) Clock.schedule_once(lambda x: menu.open(), 0)
def bind_to_keyboard_actions(self, *args): Window.fbind('on_key_down', self.on_key_down) Window.fbind('on_key_up', self.on_key_up)