def send_osc_go_on_signal(*args): osc_address = osc_go_address #send the gate on signal (ie the rising edge of the gate signal) send_osc_message(osc_address, [1.0]) #queue up the gate off signal (ie the falling edge) Clock.schedule_once(send_osc_go_off_signal, _osc_go_delay)
def on_enter(self): anim = Animation( opacity=1.0, duration=2.0) # anim &= Animation(size=[self.menu_text.size[0]+4, self.menu_text[1]+4], duration=.2) anim.start(self.story_text1) Clock.schedule_once(self.show_text2, 2.0)
def move_leftright(self, right): r = range(3, -1, -1) if right else range(4) grid = self.grid moved = False for iy in range(4): # get all the cube for the current line cubes = [] for ix in r: cube = grid[ix][iy] if cube: cubes.append(cube) # combine them self.combine(cubes) # update the grid for ix in r: cube = cubes.pop(0) if cubes else None if grid[ix][iy] != cube: moved = True grid[ix][iy] = cube if not cube: continue pos = self.index_to_pos(ix, iy) if cube.pos != pos: cube.move_to(pos) if not self.check_end() and moved: Clock.schedule_once(self.spawn_number, tempo)
def __init__(self, cache_dir='cache', **kwargs): from kivy.base import EventLoop EventLoop.ensure_window() CACHE['directory'] = cache_dir self._invalid_scale = True self._tiles = [] self._tiles_bg = [] self._tilemap = {} self._layers = [] self._default_marker_layer = None self._need_redraw_all = False self._transform_lock = False self.trigger_update(True) self.canvas = Canvas() self._scatter = MapViewScatter() self.add_widget(self._scatter) with self._scatter.canvas: self.canvas_map = Canvas() self.canvas_layers = Canvas() with self.canvas: self.canvas_layers_out = Canvas() self._scale_target_anim = False self._scale_target = 1. self._touch_count = 0 Clock.schedule_interval(self._animate_color, 1 / 60.) self.lat = kwargs.get("lat", self.lat) self.lon = kwargs.get("lon", self.lon) super(MapView, self).__init__(**kwargs)
def __init__(self, **kwargs): self.slides = [] super(Slides, self).__init__(**kwargs) Window.bind(on_keyboard=self.on_keyboard) Clock.schedule_interval(self.increase_time, 1 / 30.0) Clock.schedule_once(self.init, 0) self.add_widget(SlidesForeground(slides=self))
def _setup_default_tab(self): if self._default_tab in self.tab_list: return content = self._default_tab.content _tabs = self._tab_strip cls = self.default_tab_cls if not issubclass(cls, TabbedPanelHeader): raise TabbedPanelException('`default_tab_class` should be\ subclassed from `TabbedPanelHeader`') # no need to instanciate if class is TabbedPanelHeader if cls != TabbedPanelHeader: self._current_tab = self._original_tab = self._default_tab = cls() default_tab = self.default_tab if self._original_tab == self.default_tab: default_tab.text = self.default_tab_text default_tab.height = self.tab_height default_tab.group = '__tab%r__' % _tabs.uid default_tab.state = 'down' default_tab.width = self.tab_width if self.tab_width else 100 default_tab.content = content tl = self.tab_list if default_tab not in tl: _tabs.add_widget(default_tab, len(tl)) if default_tab.content: self.clear_widgets() self.add_widget(self.default_tab.content) else: Clock.schedule_once(self._load_default_tab_content) self._current_tab = default_tab
def __init__(self, **kwargs): kwargs.setdefault('filename', None) kwargs.setdefault('eos', 'stop') kwargs.setdefault('async', True) kwargs.setdefault('autoplay', False) super(VideoBase, self).__init__() self._wantplay = False self._buffer = None self._filename = None self._texture = None self._volume = 1. self._state = '' self._autoplay = kwargs.get('autoplay') self._async = kwargs.get('async') self.eos = kwargs.get('eos') if self.eos == 'pause': Logger.warning("'pause' is deprecated. Use 'stop' instead.") self.eos = 'stop' self.filename = kwargs.get('filename') Clock.schedule_interval(self._update, 1 / 30.) if self._autoplay: self.play()
def delete_clock(self, touch, *args): # TODO: Fix touch_up passing through when popup dismissed. try: Clock.unschedule(touch.ud['event']) except KeyError: Logger.exception( 'Application: Touch up passed through and unscheduled clock event could not be unscheduled. A bug...')
def __init__(self, **kwargs): super(Graph, self).__init__(**kwargs) self._mesh = Mesh(mode='lines') self._mesh_rect = Mesh(mode='line_strip') val = 0.25 self.canvas.add(Color(1 * val, 1 * val, 1 * val)) self.canvas.add(self._mesh) self.canvas.add(Color(1, 1, 1)) self.canvas.add(self._mesh_rect) mesh = self._mesh_rect mesh.vertices = [0] * (5 * 4) mesh.indices = [k for k in xrange(5)] self._plot_area = StencilView() self.add_widget(self._plot_area) self._trigger = Clock.create_trigger(self._redraw_all) self._trigger_size = Clock.create_trigger(self._redraw_size) self.bind(center=self._trigger_size, padding=self._trigger_size, font_size=self._trigger_size, plots=self._trigger_size, x_grid=self._trigger_size, y_grid=self._trigger_size, draw_border=self._trigger_size) self.bind(xmin=self._trigger, xmax=self._trigger, xlog=self._trigger, x_ticks_major=self._trigger, x_ticks_minor=self._trigger, xlabel=self._trigger, x_grid_label=self._trigger, ymin=self._trigger, ymax=self._trigger, ylog=self._trigger, y_ticks_major=self._trigger, y_ticks_minor=self._trigger, ylabel=self._trigger, y_grid_label=self._trigger) self._trigger()
def render_boggle_game_screen(self): logging.info("Rendering game screen.") self.clear_widgets() def handle_swipe_callback(self): # TODO: add in swipes or keyboard for user to input words. pass self.solve_boggle.set_board(self.num_columns, self.num_rows, None) logging.info("Solve Boggle created.") self.render_boggle_layout("", handle_swipe_callback, self.grid) logging.info("About to loop through buttons.") for i, button in enumerate(self.buttons): if i not in self.ignore: button.text = "[size=%s]%s[/size]" % (int(self.font), self.solve_boggle.boggle.boggle_array[i].upper()) else: button.text = "" timer = Label(text="%s" % self.game_time, size_hint=(1, 1.0/self.num_rows), font_size=self.font) def timer_callback(dt): timer.text = str(int(timer.text) -1) if int(timer.text) == 0: self.render_boggle_solution_screen() Clock.schedule_interval(timer_callback, 1) self.add_widget(self.grid) self.add_widget(timer) # TODO: make this part of a function for a timer callback so it doesn't take time away from displaying the screen. self.words = self.solve_boggle.solve(ignore_indexes=self.ignore) logging.info("Got words.")
def _on_click(self, sid): if sid == 'msgbox': XMessage(text='It could be your Ad', title='XMessage demo') elif sid == 'error': XError(text='Don`t panic! Its just the XError demo.') elif sid == 'confirm': XConfirmation(text='Do you see a confirmation?', on_dismiss=self._callback) elif sid == 'progress': self._o_popup = XProgress(title='PopupProgress demo', text='Processing...', max=200) Clock.schedule_once(self._progress_test, .1) elif sid == 'input': XTextInput(title='Edit text', text='I\'m a text', on_dismiss=self._callback) elif sid == 'notes': XNotes(title='Edit notes', on_dismiss=self._callback_notes, lines=['Text', 'Too many text...', 'Yet another row.']) elif sid == 'slider': self._o_popup = XSlider( min=.4, max=.9, value=.5, size_hint=(.6, .5), title_template='Slider test, Value: %0.2f', buttons=['Horizontal', 'Vertical', 'Close'], on_change=self._slider_value, on_dismiss=self._slider_click) elif sid == 'login': XAuthorization( on_dismiss=self._callback, login='******', required_fields={'login': '******', 'password': '******'}, password='******')
def build(self): """Initializes the user interface and starts timed events.""" #TODO: Reorganize and consolidate; make necessary helper functions self.title = 'Open Lighting Architecture' self.ui_queue = Queue() self.layout = BoxLayout(orientation='vertical') self.selected_universe_service = UniverseSelectedService() self.ola_listener = OLAListener(self.ui_queue, self.create_select_server, self.create_ola_client, self.start_ola, self.stop_ola) #Screen creation and layout placing self.screen_tabs = ScreenTabs() self.monitor_screen = MonitorScreen(self.ola_listener, self.selected_universe_service, name='DMX Monitor') self.console_screen = ConsoleScreen(self.ola_listener, self.selected_universe_service, name='DMX Console') self.devsets = MainScreen(self.ola_listener, self.selected_universe_service, name='Device Settings') self.screen_tabs.ids.monitor_screen.add_widget(self.monitor_screen) self.screen_tabs.ids.console_screen.add_widget(self.console_screen) self.screen_tabs.ids.settings_screen.add_widget(self.devsets) self.layout.add_widget(self.screen_tabs) Clock.schedule_interval(lambda dt: self.display_tasks(), self.EVENT_POLL_INTERVAL) Clock.schedule_interval(self._update_clock, 1 / 60.) return self.layout
def add_term_widget(self, cfg): layout = TermBoxLayout() ti = TabbedPanelHeader() ti.text = ' '.join([str(len(self.root_widget.term_panel.tab_list) + 1), 'Terminal']) ti.content = layout ti.size_hint = (1,1) self.root_widget.term_panel.add_widget(ti) session = create_session(cfg, self.create_terminal(cfg)) term_widget = TermTextInput(session) term_widget.size_hint = (1, 1) term_widget.pos_hint = {'center_y':.5, 'center_x':.5} layout.add_widget(term_widget) layout.term_widget = term_widget ti.term_widget = term_widget ti.session = session ti.session.term_widget = term_widget ti.session.terminal.term_widget = term_widget Clock.unschedule(self.root_widget.term_panel._load_default_tab_content) self.switch_to_tab(ti) conn_str = cfg.get_conn_str() if conn_str in self.conn_history: self.conn_history.remove(conn_str) self.conn_history.insert(0, conn_str)
def __init__(self, **kwargs): super(MainView, self).__init__(**kwargs) data_items = [] data_items.append(DataItem()) data_items.append(DataItem()) data_items.append(DataItem()) list_item_args_converter = lambda row_index, obj: {'text': obj.name, 'size_hint_y': None, 'height': 25} self.list_adapter = \ ListAdapter(data=data_items, args_converter=list_item_args_converter, selection_mode='single', propagate_selection_to_data=False, allow_empty_selection=False, cls=ListItemButton) self.list_view = ListView(adapter=self.list_adapter) self.add_widget(self.list_view) self.toggle = 'adding' Clock.schedule_interval(self.update_list_data, 1)
def __init__(self, **kwargs): super(TheCatWidget, self).__init__(**kwargs) Clock.schedule_interval(self.Update, 1.0 / 60.0) self._StateMachine = statemachine.StateMachine(self) self._StateMachine.SetState(statemachine.StateCatWander()) self._CatPettingCounter = 0
def on_leave(self): Clock.unschedule(self.update) self.player1.score = 0 self.player2.score = 0 for c in self.pongfloat.children: if isinstance(c, WinLabel): self.pongfloat.remove_widget(c)
def __init__(self, **kwargs): super(KYRScreenManager, self).__init__(**kwargs) self.loadAssets() self.room1 = KYRScreen(name='room1', bg = 'assets/art/room1.png', music = self.overworld, startLocations = dict(top = (512, 96), bottom = (512, 416), left = (928, 256), right = (96, 256) )) # inverse directions, based on direction you enter from self.room2 = KYRScreen(name='room2', bg = 'assets/art/room2.png', startLocations = dict(top = (512, 96), bottom = (512, 416), left = (928, 256), right = (96, 256) )) #self.add_widget(room1) #self.add_widget(room2) self.buildLocationEvent() self.transition=WipeTransition() self.switch_to(self.room1) self.room1.isCurrent = True Clock.schedule_interval(self.updatePlayerLocation, 0.5)
def setupView(self): # Check gromacs version self.checkGromacVersion() #Check if folder is exits call('mkdir '+self.dataController.getdata('path '), shell=True) call('mkdir '+self.dataController.getdata('path ')+'/run', shell=True) call('mkdir '+self.dataController.getdata('path ')+'/output', shell=True) call('mkdir '+self.dataController.getdata('path ')+'/output/receptor', shell=True) call('mkdir '+self.dataController.getdata('path ')+'/output/ligand', shell=True) call('mkdir '+self.dataController.getdata('path ')+'/analyse', shell=True) runfolders = check_output('ls '+self.dataController.getdata('path ')+'/run/', shell = True).splitlines() if len(runfolders) > 0: popup = RemoveDialog() popup.open() else: call('rm -r '+self.dataController.getdata('path ')+'/run/*', shell=True) call('rm -r '+self.dataController.getdata('path ')+'/output/ligand/*', shell=True) call('rm -r '+self.dataController.getdata('path ')+'/output/receptor/*', shell=True) self.thread = Process(target= self.gromacsRun.main) self.thread.start() #Check log repeat_times = int(self.dataController.getdata('repeat_times ')) self.progressUnit = 1000/(4.5 + repeat_times)/len(Variable.parsepdb.Ligands) self.progressPoint = 0 self.dataController.setdata('status', '') Clock.schedule_interval(self.check_log, 5) Clock.schedule_interval(self.spin_progress, 0.05) # Clock.schedule_interval(self.pymol_log, 300) #close pymol self.pymol.cmd.window('hide')
def build(self): self.settings_cls = SettingsWithSidebar game = PlanetGame(do_rotation=False,do_translation=False) # Settings come in as unicode! sunmass = float(App.get_running_app().config.get('planetapp','defaultsunmass')) game.sunmass = sunmass game.gravity = float(App.get_running_app().config.get('planetapp','gravity')) game.planetmass = float(App.get_running_app().config.get('planetapp','planetmass')) game.resetmass = float(App.get_running_app().config.get('planetapp','resetmass')) game.add_planet(True, (100,100), (0,0), sunmass, 10, (1,1,1)) Clock.schedule_interval(game.update, 1.0 / 120.0) self.root = PlanetGameLayout() self.root.add_widget(game) b = Button(text="Reset",size_hint=(.3,.05),pos_hint={'x':.7,'y':0}) b.bind(on_press=self.root.clear_planets) self.root.add_widget(b) b2 = SettingsButton(text="Settings",size_hint=(.3,.05),pos_hint={'x':.4,'y':0}) self.root.add_widget(b2) b3 = Button(text="Next",size_hint=(.3,.05),pos_hint={'x':.1,'y':0}) b3.bind(on_press=self.root.next_trajectory) self.root.add_widget(b3) self.root.reset_game()
def on_touch_down(self, touch): if self._touch: return super(ScrollView, self).on_touch_down(touch) if not self.collide_point(*touch.pos): return # support scrolling ! if self._viewport and 'button' in touch.profile and \ touch.button.startswith('scroll'): # distance available to move, if no distance, do nothing vp = self._viewport if vp.height > self.height: # let's say we want to move over 40 pixels each scroll d = (vp.height - self.height) d = self.scroll_distance / float(d) if touch.button == 'scrollup': syd = self.scroll_y - d elif touch.button == 'scrolldown': syd = self.scroll_y + d self.scroll_y = min(max(syd, 0), 1) return True self._touch = touch uid = self._get_uid() touch.grab(self) touch.ud[uid] = { 'mode': 'unknown', 'sx': self.scroll_x, 'sy': self.scroll_y, 'dt': None, 'time': touch.time_start} Clock.schedule_once(self._change_touch_mode, self.scroll_timeout/1000.) return True
def __init__(self, **kwargs): # initialize variables self._clipboard = Clipboard self.info_bubble = None self.qrscanner = None self.nfcscanner = None self.tabs = None self.is_exit = False super(ElectrumWindow, self).__init__(**kwargs) title = _('Electrum App') self.electrum_config = config = kwargs.get('config', None) self.language = config.get('language', 'en') self.network = network = kwargs.get('network', None) self.plugins = kwargs.get('plugins', []) self.gui_object = kwargs.get('gui_object', None) #self.config = self.gui_object.config self.contacts = Contacts(self.electrum_config) self.invoices = InvoiceStore(self.electrum_config) # create triggers so as to minimize updation a max of 2 times a sec self._trigger_update_wallet =\ Clock.create_trigger(self.update_wallet, .5) self._trigger_update_status =\ Clock.create_trigger(self.update_status, .5) self._trigger_notify_transactions = \ Clock.create_trigger(self.notify_transactions, 5)
def build(self): self.service = None self.start_service() global RootApp RootApp = self # NavigationDrawer self.navigationdrawer = NavDrawer() # SidePanel side_panel = SidePanel() self.navigationdrawer.add_widget(side_panel) # MainPanel self.main_panel = MainPanel() # color picker self.color_selector = ColorSelector() # size selector self.size_selector = SizeSelector() self.navigationdrawer.anim_type = 'slide_above_simple' self.navigationdrawer.add_widget(self.main_panel) osc.init() oscid = osc.listen(port=3002) osc.bind(oscid, self.reCallback, '/date') Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0) return self.navigationdrawer
def _sign_tx(self, tx, password, on_success, on_failure): try: self.wallet.sign_transaction(tx, password) except InvalidPassword: Clock.schedule_once(lambda dt: on_failure(_("Invalid PIN"))) return Clock.schedule_once(lambda dt: on_success(tx))
def __init__(self, **kwargs): # Make sure opengl context exists EventLoop.ensure_window() self.canvas = RenderContext(use_parent_projection=True, use_parent_modelview=True) with self.canvas: self.fbo = Fbo(size=self.size) with self.fbo.before: PushMatrix() with self.fbo: ClearColor(0, 0, 0, 0) ClearBuffers() self._background_color = Color(*self.background_color) self.fbo_rectangle = Rectangle(size=self.size) with self.fbo.after: PopMatrix() super(EffectWidget, self).__init__(**kwargs) Clock.schedule_interval(self._update_glsl, 0) self.bind(size=self.refresh_fbo_setup, effects=self.refresh_fbo_setup, background_color=self._refresh_background_color) self.refresh_fbo_setup() self._refresh_background_color() # In case thi was changed in kwargs
def __init__(self, **kwargs): self.register_event_type('on_subprocess_done') super(KivyConsole, self).__init__(**kwargs) # initialisations self.txtinput_command_line_refocus = False self.txtinput_run_command_refocus = False self.win = None self.scheduled = False self.command_history = [] self.command_history_pos = 0 self.command_status = 'closed' if sys.version_info >= (3, 0): self.cur_dir = os.getcwd() else: self.cur_dir = os.getcwdu() self.stdout = std_in_out(self, 'stdout') self.stdin = std_in_out(self, 'stdin') # self.stderror = stderror(self) # delayed initialisation Clock.schedule_once(self._initialize) self_change_txtcache = self._change_txtcache _trig = Clock.create_trigger(self_change_txtcache) self.bind(textcache=_trig) self._hostname = 'unknown' try: if hasattr(os, 'uname'): self._hostname = os.uname()[1] else: self._hostname = os.environ.get('COMPUTERNAME', 'unknown') except Exception: pass self._username = os.environ.get('USER', '') if not self._username: self._username = os.environ.get('USERNAME', 'unknown')
def move_topdown(self, top, from_keyboard=False): r = range(self.dim - 1, -1, -1) if top else range(self.dim) grid = self.grid moved = False for ix in range(self.dim): # get all the cube for the current line cubes = [] for iy in r: cube = grid[ix][iy] if cube: cubes.append(cube) # combine them self.combine(cubes) # update the grid for iy in r: cube = cubes.pop(0) if cubes else None if grid[ix][iy] != cube: moved = True grid[ix][iy] = cube if not cube: continue pos = self.index_to_pos(ix, iy) if cube.pos != pos: cube.move_to(pos) if from_keyboard: return moved elif not self.check_end() and moved: Clock.schedule_once(self.spawn_number, .20)
def __init__(self): android.accelerometer_enable(True) Clock.schedule_interval(self.detect_motion, 0.1) self.last = None self.history = deque() self.shake_callback = None self.enabled = True
def my_screen(self): self.ws = WeatherScreen() self._image_path = os.path.join(graphics_dir, "na.png") self.ws.change_image(self._image_path, self._image_path) self._weather_updater() Clock.schedule_interval(self._weather_updater, 300) return self.ws
def next(self,*largs): Clock.unschedule(self.next) if(self.screenManager.current == 'page1'): next = 'page2' page = self.page2 else: next = 'page1' page = self.page1 self.index += 1 if self.index == len(self.photos): self.index = 0 page.source = self.photos[self.index] page.background.scale = 1.0 self.screenManager.transition = self.transitions[random.randint(0, len(self.transitions) -1)] self.screenManager.current = next anim = Animation( scale=page.background.scale*1.3, duration=15.0 ) Clock.schedule_once(self.next, 10) anim.start(page.background)
def anim_reset(self, allow_anim): '''Reset an animation if available. .. versionadded:: 1.0.8 :Parameters: `allow_anim`: bool Indicate whether the animation should restart playing or not. Usage:: # start/reset animation image.anim_reset(True) # or stop the animation image.anim_reset(False) You can change the animation speed whilst it is playing:: # Set to 20 FPS image.anim_delay = 1 / 20. ''' # stop animation Clock.unschedule(self._anim) if allow_anim and self._anim_available: Clock.schedule_interval(self._anim, self.anim_delay) self._anim()