Python kivy.clock.Clock.schedule_once() Examples

The following are 30 code examples of kivy.clock.Clock.schedule_once(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module kivy.clock.Clock , or try the search function .
Example #1
Source File: screen.py    From RPi-InfoScreen-Kivy with GNU General Public License v3.0 7 votes vote down vote up
def on_enter(self):
        # Refresh the information when we load the screen
        Clock.schedule_once(self.get_buses, 0.5)

        # and schedule updates every 30 seconds.
        self.timer = Clock.schedule_interval(self.get_buses, 3)
        # We only need to update the clock every second.
        self.stimer = Clock.schedule_interval(self.update, 1) 
Example #2
Source File: generalelements.py    From Snu-Photo-Manager with GNU Lesser General Public License v3.0 6 votes vote down vote up
def _load_source(self, *_):
        self.set_angle()
        source = self.source
        photo = self.photoinfo
        self.nocache = True
        if not source and not photo:
            if self._coreimage is not None:
                self._coreimage.unbind(on_texture=self._on_tex_change)
            self.texture = None
            self._coreimage = None
        elif not photo:
            Clock.schedule_once(lambda *dt: self._load_source(), .25)
        else:
            ThumbLoader.max_upload_per_frame = 50
            ThumbLoader.num_workers = 4
            ThumbLoader.loading_image = 'data/loadingthumbnail.png'
            self._coreimage = image = ThumbLoader.image(source, load_callback=self.load_thumbnail, nocache=self.nocache, mipmap=self.mipmap, anim_delay=self.anim_delay)
            image.bind(on_load=self._on_source_load)
            image.bind(on_texture=self._on_tex_change)
            self.texture = image.texture 
Example #3
Source File: simulationCanvas.py    From GroundControl with GNU General Public License v3.0 6 votes vote down vote up
def initialize(self):
        
        self.motorSpacingError.bind(value=self.onSliderChange)
        self.motorVerticalError.bind(value=self.onSliderChange)
        self.sledMountSpacingError.bind(value=self.onSliderChange)
        self.vertBitDist.bind(value=self.onSliderChange)
        self.leftChainOffset.bind(value=self.onSliderChange)
        self.rightChainOffset.bind(value=self.onSliderChange)
        self.rotationRadiusOffset.bind(value=self.onSliderChange)
        self.chainSagCorrectionOffset.bind(value=self.onSliderChange)

        self.vertCGDist.bind(value=self.onSliderChange)
        self.gridSize.bind(value=self.onSliderChange)
        
        Clock.schedule_once(self.moveToCenter, 3)
        
        #start with our current kinematics type
        self.kinematicsSelect.text = self.data.config.get('Advanced Settings', 'kinematicsType')
          
        self.recompute() 
Example #4
Source File: __init__.py    From kivystudio with MIT License 6 votes vote down vote up
def add_widget(self, widget, title=''):
        if len(self.children) > 1:
            tab = TerminalTab()
            tab.text=title
            tab.name=title
            tab.bind(state=self.tab_state)
            self.tab_container.add_widget(tab)
            Clock.schedule_once(lambda dt: setattr(tab, 'state', 'down'))
            screen = Screen(name=title)
            screen.add_widget(widget)
            self.manager.add_widget(screen)
        else:
            super(TerminalSpace, self).add_widget(widget) 
Example #5
Source File: __init__.py    From kivystudio with MIT License 6 votes vote down vote up
def change_scroll_y(self, txt, scroll):
        if self._do_cursor_scroll:

            lines_lenght = len(txt._lines)
            line_pos = txt.cursor_row +1

            norm_y = float(line_pos) / lines_lenght
            scroll.scroll_y  = abs(norm_y-1)
            if line_pos == 1:
                scroll.scroll_y  = 1

        # scroll scroll numbers
        line_num =  txt.cursor_row + 1
        children = self.ids.numbering.children[::-1]
        if children:
            child = children[line_num-1]
            self.ids.number_scroll.scroll_to(child, dp(5))

            Clock.schedule_once(lambda dt: setattr(child, 'state', 'down'))
            def toggle(chd):
                if chd!=child:
                    chd.state='normal'
            map(lambda child: toggle, ToggleButtonBehavior.get_widgets(child.group)) 
Example #6
Source File: screen.py    From RPi-InfoScreen-Kivy with GNU General Public License v3.0 6 votes vote down vote up
def on_enter(self):

        if not self.running:

            # The screen hasn't been run before so let's tell the user
            # that we need to get the photos
            self.loading = PhotoLoading(name="loading")
            self.photoscreen.add_widget(self.loading)
            self.photoscreen.current = "loading"

            # Retrieve photos
            Clock.schedule_once(self.getPhotos, 0.5)

        else:
            # We've been here before so just show the photos
            self.timer = Clock.schedule_interval(self.showPhoto,
                                                 self.photoduration) 
Example #7
Source File: modernMenu.py    From GroundControl with GNU General Public License v3.0 6 votes vote down vote up
def open_menu(self, *args):
        
        self.clear_widgets()
        for i in self.choices:
            kwargs = copy(self.item_args)
            kwargs.update(i)
            ml = self.item_cls(**kwargs)
            try:
                if ml.text == 'Position Text Placeholder':
                    ml.text = '[color=3333ff]X: ' + str('%.3f'%(self.xPosition)) + 'mm\nY: ' + str('%.3f'%(self.yPosition)) + 'mm [/color]'
                if ml.text == '[color=3333ff]Move Here[/color]':
                    ml.callback = partial(self.parent.parent.parent.moveToPos, self.xPosition, self.yPosition)
                if ml.text == '[color=3333ff]Mark Here[/color]':
                    ml.callback = partial(self.parent.parent.parent.createMark, self.xPosition, self.yPosition)
                if ml.text == '[color=3333ff]Set Home[/color]':
                    ml.callback = partial(self.parent.parent.parent.setHome, self.xPosition, self.yPosition)
            except:
                print "unable to link circular menu functions"
            self.animation.start(ml)
            self.add_widget(ml)
            
        
        Clock.schedule_once(self.dismiss, self.close_After_Timeout) #close the menu if not used for close_After_Timeout seconds 
Example #8
Source File: gcodeCanvas.py    From GroundControl with GNU General Public License v3.0 6 votes vote down vote up
def callBackMechanism(self, callback) :
        '''
        
        Call the loadNextLine function periodically in a non-blocking way to
        update the gcode.
        
        '''
        
        with self.scatterObject.canvas:
            self.line = Line(points = (), width = 1, group = 'gcode')
        
        #Draw numberOfTimesToCall lines on the canvas
        numberOfTimesToCall = 500
        for _ in range(numberOfTimesToCall):
            self.loadNextLine()
        
        #Repeat until end of file
        if self.lineNumber < min(len(self.data.gcode),self.maxNumberOfLinesToRead):
            Clock.schedule_once(self.callBackMechanism) 
Example #9
Source File: codeplace.py    From kivystudio with MIT License 6 votes vote down vote up
def add_widget(self, widget, tab_type=''):
        if len(self.children) > 1:
            if tab_type =='code' or tab_type =='new_file' or tab_type=='unsupported':
                tab = TabToggleButton(text=os.path.split(widget.filename)[1],
                                    filename=widget.filename)
                widget.tab = tab
                widget.tab_type = tab_type
                self.code_manager.add_widget(widget, widget.filename, tab_type=tab_type)

            elif tab_type=='welcome':
                self.code_manager.add_widget(widget, 'kivystudiowelcome', tab_type=tab_type)
                tab = TabToggleButton(text='Welcome',filename='kivystudiowelcome')

            tab.bind(state=self.change_screen)
            self.tab_manager.add_widget(tab)
            Clock.schedule_once(lambda dt: setattr(tab, 'state', 'down'))

        else:
            super(CodePlace, self).add_widget(widget) 
Example #10
Source File: main.py    From Snu-Photo-Manager with GNU Lesser General Public License v3.0 6 votes vote down vote up
def program_run(self, index, button):
        """Loads the currently viewed photo in an external program using an external program preset.
        Argument:
            index: Integer, index of the preset to use.
            button: Widget, the button that called this function.
        """

        name, command, argument = self.programs[index]
        if os.path.isfile(command):
            button.disabled = True  # Disable the button so the user knows something is happening
            photo_info = self.database_exists(self.fullpath)
            if photo_info:
                photo_file = os.path.join(photo_info[2], photo_info[0])
                abs_photo = os.path.abspath(photo_file)
                argument_replace = argument.replace('%i', '"'+abs_photo+'"')
                argument_replace = argument_replace.replace('%%', '%')

                run_command = command+' '+argument_replace
                Clock.schedule_once(lambda *dt: self.program_run_finish(run_command, photo_info, button))
        else:
            self.popup_message(text='Not A Valid Program') 
Example #11
Source File: main.py    From Snu-Photo-Manager with GNU Lesser General Public License v3.0 6 votes vote down vote up
def rescale_interface(self, *_, force=False):
        if self.last_width == 0:
            first_change = True
        else:
            first_change = False
        if Window.width != self.last_width or force:
            self.popup_x = int(Window.width * .75)
            self.last_width = Window.width
            if first_change:
                Clock.schedule_once(lambda x: self.rescale_interface(force=True))
                return
            if desktop:
                button_multiplier = 1
            else:
                button_multiplier = 2
            self.button_scale = int((Window.height / interface_multiplier) * int(self.config.get("Settings", "buttonsize")) / 100) * button_multiplier
            self.padding = self.button_scale / 4
            self.text_scale = int((self.button_scale / 3) * int(self.config.get("Settings", "textsize")) / 100)
            if self.standalone:
                Clock.schedule_once(lambda x: self.show_album())
            else:
                Clock.schedule_once(self.show_database) 
Example #12
Source File: text_editor.py    From kivy-smoothie-host with GNU General Public License v3.0 6 votes vote down vote up
def insert(self, before):
        # now see which line is selected and insert before or after that
        i = self.rv.selected_idx
        if i < 0:
            # print("No line is selected")
            return
        if not before:
            # insert after selected line
            i = i + 1

        self.rv.data.insert(i, {'value': "ENTER TEXT", 'index': i, 'ro': False})
        self.max_cnt += 1
        # we need to renumber all following lines
        for j in range(i + 1, self.max_cnt):
            self.rv.data[j]['index'] = j

        self.rv.refresh_from_data()
        Clock.schedule_once(partial(self._refocus_it, i), 0.3) 
Example #13
Source File: colorpickercustom.py    From Snu-Photo-Manager with GNU Lesser General Public License v3.0 5 votes vote down vote up
def inertial_incr_sv_idx(self, dt):
        # if its already zoomed all the way out, cancel the inertial zoom
        if self.sv_idx == len(self.sv_s) - self._piece_divisions:
            return False

        self.sv_idx += 1
        self.recolor_wheel()
        if dt * self._inertia_slowdown > self._inertia_cutoff:
            return False
        else:
            Clock.schedule_once(self.inertial_incr_sv_idx,
                                dt * self._inertia_slowdown) 
Example #14
Source File: colorpickercustom.py    From Snu-Photo-Manager with GNU Lesser General Public License v3.0 5 votes vote down vote up
def on_touch_up(self, touch):
        if touch.grab_current is not self:
            return
        touch.ungrab(self)
        self._num_touches -= 1
        if self._pinch_flag:
            if self._num_touches == 0:
                # user was pinching, and now both fingers are up. Return
                # to normal
                if self.sv_idx > touch.ud['orig_sv_idx']:
                    Clock.schedule_once(
                        self.inertial_incr_sv_idx,
                        (Clock.get_time() - touch.ud['orig_time']) /
                        (self.sv_idx - touch.ud['orig_sv_idx']))

                if self.sv_idx < touch.ud['orig_sv_idx']:
                    Clock.schedule_once(
                        self.inertial_decr_sv_idx,
                        (Clock.get_time() - touch.ud['orig_time']) /
                        (self.sv_idx - touch.ud['orig_sv_idx']))

                self._pinch_flag = False
                return
            else:
                # user was pinching, and at least one finger remains. We
                # don't want to treat the remaining fingers as touches
                return
        else:
            r, theta = rect_to_polar(self._origin, *touch.pos)
            # if touch up is outside the wheel, ignore
            if r >= self._radius:
                return
            # compute which ColorArc is being touched (they aren't
            # widgets so we don't get collide_point) and set
            # _hsv based on the selected ColorArc
            piece = int((theta / (2 * pi)) * self._pieces_of_pie)
            division = int((r / self._radius) * self._piece_divisions)
            self._hsv = \
                self.arcs[self._pieces_of_pie * division + piece].color 
Example #15
Source File: screen.py    From RPi-InfoScreen-Kivy with GNU General Public License v3.0 5 votes vote down vote up
def on_enter(self):
        """Start the screen running."""
        self.timer = Clock.schedule_once(self.update, 0.1)
        if self.now_playing:
            self.now_playing.start() 
Example #16
Source File: generalelements.py    From Snu-Photo-Manager with GNU Lesser General Public License v3.0 5 votes vote down vote up
def reload_video_edit_image(self):
        location = self.length * self.position
        frame = self.seek_player(location)
        Clock.schedule_once(self.reload_edit_image) 
Example #17
Source File: resize.py    From Snu-Photo-Manager with GNU Lesser General Public License v3.0 5 votes vote down vote up
def __init__(self, **kwargs):
        super(ResizableBehavior, self).__init__(**kwargs)
        self.modalview = CursorModalView()
        self.cursor = self.modalview.cursor
        Window.bind(mouse_pos=self.on_mouse_move)
        Clock.schedule_once(self.modalview.put_on_top, 0)
        self.oldpos, self.oldsize = [], [] 
Example #18
Source File: main.py    From Snu-Photo-Manager with GNU Lesser General Public License v3.0 5 votes vote down vote up
def message(self, text, timeout=20):
        """Sets the app.infotext variable to a specific message, and clears it after a set amount of time."""

        self.infotext = text
        if self.infotext_setter:
            self.infotext_setter.cancel()
        self.infotext_setter = Clock.schedule_once(self.clear_message, timeout) 
Example #19
Source File: main.py    From Snu-Photo-Manager with GNU Lesser General Public License v3.0 5 votes vote down vote up
def on_config_change(self, config, section, key, value):
        self.animations = to_bool(self.config.get("Settings", "animations"))
        self.set_transition()
        self.simple_interface = to_bool(self.config.get("Settings", "simpleinterface"))
        self.thumbsize = int(self.config.get("Settings", "thumbsize"))
        if key == 'buttonsize' or key == 'textsize':
            self.rescale_interface(force=True)
            Clock.schedule_once(self.database_screen.on_enter) 
Example #20
Source File: interpreter.py    From Pyonic-interpreter with GNU General Public License v3.0 5 votes vote down vote up
def on__output_label_queue(self, instance, values):
        # print('olq', self.dequeue_scheduled, self.clear_scheduled)
        if self.dequeue_scheduled:
            return

        if not self.dequeue_scheduled:
            self.dequeue_scheduled = Clock.schedule_once(self._dequeue_output_label, 0)
        if not self.clear_scheduled:
            self.clear_scheduled = Clock.schedule_once(
                self._clear_output_label_queue, 1) 
Example #21
Source File: screen.py    From RPi-InfoScreen-Kivy with GNU General Public License v3.0 5 votes vote down vote up
def update(self, cur_track):
        """Updates the player for the information of the currently playing
           track.
        """
        # If it's a new track then we need to update the playlist to make
        # sure the currently playing track is highlighted.
        if cur_track["pos"] != self.cur_track["pos"]:
            for c in self.sv_playlist.children:

                # This will raise an error when it tries to update the
                # "Refresh" button, so let's make sure we catch it.
                try:
                    c.updatePlaylistPosition(cur_track["pos"])
                except AttributeError:
                    pass

        # Set the local flag (so we can check it later)
        self.cur_track = cur_track

        self.album_name = self.cur_track.get("album", "")
        self.track_name = self.cur_track.get("title", "")
        self.artist_name = self.cur_track.get("artist", "")

        if self.album_name == "Playlist is empty":
            Clock.schedule_once(self.refresh_playlist, 1)

        # Update the track time info
        self.updatePlayTime(cur_track)

        # No harm checking the volume too
        self.vol = int(float(self.player.get_volume())) 
Example #22
Source File: screen.py    From RPi-InfoScreen-Kivy with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, **kwargs):
        super(SqueezePlaylistItem, self).__init__(**kwargs)
        # Create references to underlying objects
        self.player = kwargs["player"]
        self.np = kwargs["np"]

        # Set the display properties
        try:
            self.artwork = kwargs["track"]["art"]
            self.artist = kwargs["track"]["artist"]
            self.trackname = kwargs["track"]["title"]
            self.posnum = str(kwargs["track"]["pos"])

        # Sometimes the server hasn't loaded all the metadata yet
        except KeyError:

            # Create a dummy entry in the playlist
            self.artwork = "10x10_transparent.png"
            self.artist = "Loading..."
            self.trackname = "Loading..."
            self.posnum = "0"

            # but schedule a refresh of the playlist
            Clock.schedule_once(self.np.refresh_playlist, 2)

        # Check if we're the current track
        self.updatePlaylistPosition(self.np.cur_track["pos"]) 
Example #23
Source File: main.py    From kb with MIT License 5 votes vote down vote up
def desktop_loaded(self, desktop):
        if desktop.image.texture:
            self.root.ids.desktop.texture = \
                desktop.image.texture
        del desktop

        Clock.schedule_once(self.reload_desktop, 1)

        if self.root.current == 'login':
            self.root.current = 'desktop' 
Example #24
Source File: main.py    From launcher with GNU General Public License v2.0 5 votes vote down vote up
def _trigger_update_hex(self, text):
        self._upd_hex_list = text
        Clock.unschedule(self._update_hex)
        Clock.schedule_once(self._update_hex) 
Example #25
Source File: main.py    From launcher with GNU General Public License v2.0 5 votes vote down vote up
def _trigger_update_clr(self, mode, clr_idx, text):
        self._upd_clr_list = mode, clr_idx, text
        Clock.unschedule(self._update_clr)
        Clock.schedule_once(self._update_clr) 
Example #26
Source File: main.py    From launcher with GNU General Public License v2.0 5 votes vote down vote up
def _trigger_update_hex(self, text):
        self._upd_hex_list = text
        Clock.unschedule(self._update_hex)
        Clock.schedule_once(self._update_hex) 
Example #27
Source File: main.py    From launcher with GNU General Public License v2.0 5 votes vote down vote up
def _trigger_update_clr(self, mode, clr_idx, text):
        self._upd_clr_list = mode, clr_idx, text
        Clock.unschedule(self._update_clr)
        Clock.schedule_once(self._update_clr) 
Example #28
Source File: main.py    From Pyonic-interpreter with GNU General Public License v3.0 5 votes vote down vote up
def parse_args(self):
        print('args are', sys.argv[1:])
        parser = argparse.ArgumentParser()
        parser.add_argument('--test', choices=['interpreter'])

        args = parser.parse_args(sys.argv[1:])

        if args.test == 'interpreter':
            Clock.schedule_once(self.test_interpreter, 0) 
Example #29
Source File: main.py    From Pyonic-interpreter with GNU General Public License v3.0 5 votes vote down vote up
def build(self):
        self.settings_retrieved = False  # used to prevent setting
                                         # updates until they have
                                         # been fetched from the file

        Window.clearcolor = (1, 1, 1, 1)
        Window.softinput_mode = 'pan'

        self.parse_args()
        Clock.schedule_once(self.android_setup, 0)
        Clock.schedule_once(self.retrieve_settings, 0)

        if platform == 'android':
            settings_path = '../settings.json'
        else:
            settings_path = join(abspath(dirname(__file__)), '..', 'settings.json')
        self.store = SettingsStore(settings_path)

        # Retrieve the input throttling argument so that it can be
        # passed to the service immediately
        self.setting__throttle_output = self.store.get(
            'setting__throttle_output',
            {'value': self.setting__throttle_output_default})['value']

        Window.bind(on_keyboard=self.key_input)

        for attr in dir(self):
            if attr.startswith('setting__') and not attr.endswith('_default'):
                self.bind(**{attr: partial(self.setting_updated, attr)})

        self.manager = Manager()

        return self.manager 
Example #30
Source File: interpreterwrapper.py    From Pyonic-interpreter with GNU General Public License v3.0 5 votes vote down vote up
def ping(self, *args, **kwargs):
        timeout = kwargs.get('timeout', 2)
        self.send_osc_message(b'ping', address=b'/ping')
        Clock.schedule_once(self.ping_failed, timeout)