Python gi.repository.GObject.timeout_add() Examples
The following are 30
code examples of gi.repository.GObject.timeout_add().
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
gi.repository.GObject
, or try the search function
.
Example #1
Source File: browser_cef.py From rednotebook with GNU General Public License v2.0 | 6 votes |
def __init__(self): super().__init__() self._browser = None self._win32_handle = None self._initial_html = "" sys.excepthook = cef.ExceptHook # To shutdown CEF processes on error. cef.Initialize(settings={"context_menu": {"enabled": False}}) GObject.threads_init() GObject.timeout_add(10, self.on_timer) self.connect("configure-event", self.on_configure) self.connect("size-allocate", self.on_size_allocate) self.connect("focus-in-event", self.on_focus_in) self.connect("realize", self.on_realize)
Example #2
Source File: ui.py From runsqlrun with MIT License | 6 votes |
def on_query_changed(self, editor): if editor is None: self.lbl_query.set_text('') return query = editor.get_active_query() if query is None or query.failed: self.lbl_query.set_text('') elif query.finished: self.lbl_query.set_text(query.get_result_summary()) elif query.pending: self.lbl_query.set_text('Pending...') GObject.timeout_add(10, self.on_query_changed, self._editor) else: duration = time.time() - query.start_time self.lbl_query.set_text('Running for {} seconds'.format( locale.format('%.3f', duration, grouping=True))) GObject.timeout_add(10, self.on_query_changed, self._editor)
Example #3
Source File: downloads.py From tartube with GNU General Public License v3.0 | 6 votes |
def nudge_progress_bar (self): """Can be called by anything. Called by self.run() during the download operation. Also called by code in other files, just after that code adds a new media data object to our download list. Updates the main window's progress bar. """ if DEBUG_FUNC_FLAG: utils.debug_time('dld 616 nudge_progress_bar') if self.current_item_obj: GObject.timeout_add( 0, self.app_obj.main_win_obj.update_progress_bar, self.current_item_obj.media_data_obj.name, self.job_count, len(self.download_list_obj.download_item_list), )
Example #4
Source File: tag_editor.py From gtg with GNU General Public License v3.0 | 6 votes |
def on_tn_entry_changed(self, widget): """ Callback: checks tag name validity and start value changes monitoring to decide when to update a tag's name.""" self.tn_entry_last_recorded_value = self.get_tn_text() # check validity if self.tn_entry_last_recorded_value == "": self.tn_entry.set_icon_from_icon_name( Gtk.EntryIconPosition.SECONDARY, Gtk.STOCK_DIALOG_ERROR) else: self.tn_entry.set_icon_from_icon_name( Gtk.EntryIconPosition.SECONDARY, None) # filter out change requests to reduce commit overhead if self.tn_entry_watch_id is None: # There is no watchers for the text entry. Register one. # Also, wait 1 second before commiting the change in order to # reduce rename requests tn_entry_changes = self.watch_tn_entry_changes self.tn_entry_watch_id = GObject.timeout_add(1000, tn_entry_changes)
Example #5
Source File: main_window.py From ebook-viewer with GNU General Public License v3.0 | 6 votes |
def load_book_data(self, filename): """ Loads book to Viwer and moves to correct chapter and scroll position :param filename: """ self.spinner.start() self.viewer.hide() self.right_box.add(self.spinner) self.filename = filename if not filename.upper().endswith(tuple(constants.NATIVE)): convert_thread = threading.Thread(target=self.__bg_import_book, args=(filename,)) self.job_running = True convert_thread.start() GObject.timeout_add(100, self.__check_on_work) else: self.__continiue_book_loading(filename)
Example #6
Source File: widgets.py From zim-desktop-wiki with GNU General Public License v2.0 | 6 votes |
def on_size_allocate(self, allocation): # remove timer if any if self._render_timeout: GObject.source_remove(self._render_timeout) self._render_timeout = None size = (allocation.width, allocation.height) if size == self._render_size or not self._pixbuf: pass # no update of rendering needed else: def render_on_timeout(size): self._render_size = size try: self._render() except: logger.exception('Exception while rendering image') return False self._render_timeout = GObject.timeout_add(100, render_on_timeout, size)
Example #7
Source File: listener.py From pulseaudio-dlna with GNU General Public License v3.0 | 6 votes |
def run(self, ttl=None): if self.DISABLE_SSDP_LISTENER: return self.allow_reuse_address = True SocketServer.UDPServer.__init__( self, (self.host or '', self.SSDP_PORT), SSDPHandler) self.socket.setsockopt( socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, self._multicast_struct(self.SSDP_ADDRESS)) self.socket.setsockopt( socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, self.SSDP_TTL) if ttl: GObject.timeout_add(ttl * 1000, self.shutdown) setproctitle.setproctitle('ssdp_listener') self.serve_forever(self) logger.info('SSDPListener.run()')
Example #8
Source File: message_bar.py From hazzy with GNU General Public License v2.0 | 5 votes |
def set_timout(self, timeout): if self.time_out_id: # Remove any active timeout GObject.source_remove(self.time_out_id) self.time_out_id = None if timeout: self.time_out_id = GObject.timeout_add(timeout * 1000, self.close)
Example #9
Source File: results.py From runsqlrun with MIT License | 5 votes |
def _update_current(self, query): model = self.get_model() model.set_value(model.get_iter_first(), 0, self._get_markup(query)) if not query.finished: GObject.timeout_add(17, self._update_current, query) elif query.failed: model.set_value(model.get_iter_first(), 1, self.col_error)
Example #10
Source File: streamserver.py From pulseaudio-dlna with GNU General Public License v3.0 | 5 votes |
def unregister(self, stream): logger.info('Unregistered stream "{}" ({}) ...'.format( stream.path, stream.id)) del self.streams[stream.path][stream.id] if stream.path in self.timeouts: GObject.source_remove(self.timeouts[stream.path]) self.timeouts[stream.path] = GObject.timeout_add( 2000, self._on_disconnect, stream)
Example #11
Source File: mainwin.py From runsqlrun with MIT License | 5 votes |
def __init__(self, app): super(MainWindow, self).__init__(application=app, title='RunSQLRun') self.app = app self._internal_state = {} self.set_default_size(800, 600) self.set_icon(Pixbuf.new_from_resource( '/org/runsqlrun/icons/runsqlrun.svg')) self.headerbar = HeaderBar(self) self.set_titlebar(self.headerbar) self.docview = DocViewer(self) self.statusbar = Gtk.Statusbar() self.statusbar.set_margin_top(0) self.statusbar.set_margin_bottom(0) self.statusbar.push(303, 'Ready when you are') GObject.timeout_add(3000, self.statusbar.pop, 303) self.statusbar.set_spacing(6) self.statusbar.pack_end(ConnectionIndicator(self), False, False, 0) vbox = Gtk.VBox() vbox.pack_start(self.docview, True, True, 0) vbox.pack_start(self.statusbar, False, False, 0) self.add(vbox) # TODO: Statusbar # track window settings self.connect('window-state-event', self.on_window_state_event) self.connect('configure-event', self.on_configure_event) # Actions self._setup_actions() self.show_all()
Example #12
Source File: cpu_temperature.py From python-bluezero with MIT License | 5 votes |
def _update_temp_value(self): if not self.props[constants.GATT_CHRC_IFACE]['Notifying']: return print('Starting timer event') GObject.timeout_add(500, self.temperature_cb)
Example #13
Source File: async_tools.py From python-bluezero with MIT License | 5 votes |
def add_timer(self, time, callback): GObject.timeout_add(time, callback)
Example #14
Source File: gremlin3d.py From hazzy with GNU General Public License v2.0 | 5 votes |
def map(self, *args): GObject.timeout_add(50, self.poll)
Example #15
Source File: main_window.py From rednotebook with GNU General Public License v2.0 | 5 votes |
def start_countdown(self): self.time_left = self.timespan self.countdown = GObject.timeout_add(1000, self.count_down)
Example #16
Source File: gremlin3dwidget.py From hazzy with GNU General Public License v2.0 | 5 votes |
def on_zoom_in_pressed(self, widget, data=None): self.zoom_in_pressed = True GObject.timeout_add(50, self.zoom) self.set_image('zoom_in_image', 'plus_selected.png')
Example #17
Source File: gremlin3dwidget.py From hazzy with GNU General Public License v2.0 | 5 votes |
def on_zoom_out_pressed(self, widget, data=None): self.zoom_out_pressed = True GObject.timeout_add(50, self.zoom) self.set_image('zoom_out_image', 'minus_selected.png')
Example #18
Source File: keyboard.py From hazzy with GNU General Public License v2.0 | 5 votes |
def emulate_key(self, widget, event=None, key=None): try: event = Gdk.Event.new(Gdk.EventType.KEY_PRESS) if key: event.keyval = int(key) else: event.keyval = ord(widget.get_label()) event.hardware_keycode = _keymap.get_entries_for_keyval(event.keyval)[1][0].keycode # add control mask if ctrl is active if self.builder.get_object('ctrl').get_active(): event.state = Gdk.ModifierType.CONTROL_MASK self.builder.get_object('ctrl').set_active(False) #self.entry.get_parent_window() # FIXME This is a kludge to get the window for both Entry and TextView try: event.window = self.entry.get_window() except TypeError: event.window = self.entry.get_window(Gtk.TextWindowType.TEXT) self.entry.event(event) # Do the initial event # Call key repeat function every 50ms self.wait_counter = 0 # Set counter for repeat timeout GObject.timeout_add(50, self.key_repeat, widget, event) except Exception as e: log.exception(e) # Unshift if left shift is active, right shift is "sticky" if self.builder.get_object('left_shift').get_active(): self.shift(False)
Example #19
Source File: tableeditor.py From zim-desktop-wiki with GNU General Public License v2.0 | 5 votes |
def on_focus_out(self, treeview, event, toolbar): '''After a table is deselected, this function will be triggered''' def receive_alarm(): if self._keep_toolbar_open: self._timer = None if self._timer: self._timer = None treeview.get_selection().unselect_all() if self._toolbar_enabled: toolbar.hide() return False self._timer = GObject.timeout_add(500, receive_alarm)
Example #20
Source File: main.py From zim-desktop-wiki with GNU General Public License v2.0 | 5 votes |
def testGtk(self): app = ZimApplication() class MockCmd(GtkCommand): def __init__(self): self.opts = {'standalone': True} self.hasrun = False def _quit(self, *a): from gi.repository import GObject from gi.repository import Gtk Gtk.main_quit() return False # stop timer def run(self): from gi.repository import GObject from gi.repository import Gtk self.hasrun = True GObject.timeout_add(500, self._quit) return Gtk.Window() cmd = MockCmd() self.assertFalse(cmd.hasrun) app._run_cmd(cmd, ()) self.assertTrue(cmd.hasrun)
Example #21
Source File: audiotsmgtk.py From audiotsm with MIT License | 5 votes |
def _on_state_changed(self, bus, message): """Called when the state of an element of the pipeline changes.""" state = message.parse_state_changed()[1] if message.src != self.playbin: # Ignore messages that do not come from the playbin return if state == Gst.State.READY: self._speed_set = False if state == Gst.State.PAUSED: self._emit_position() if state == Gst.State.PLAYING: if not self._speed_set: self._speed_set = True self.playbin.seek( self._speed, Gst.Format.TIME, Gst.SeekFlags.FLUSH, Gst.SeekType.SET, 0, Gst.SeekType.NONE, -1) if self.position_timer is None: self._emit_position() self.position_timer = ( GObject.timeout_add(100, self._emit_position) ) else: if self.position_timer is not None: GObject.source_remove(self.position_timer) self.position_timer = None self.emit('state-changed', state)
Example #22
Source File: __init__.py From zim-desktop-wiki with GNU General Public License v2.0 | 5 votes |
def _start_timer(self): timeout = 60000 * self.plugin.preferences['autosave_interval'] self._autosave_timer = GObject.timeout_add( timeout, self.do_save_version_async)
Example #23
Source File: file_dialog.py From bokken with GNU General Public License v2.0 | 5 votes |
def _validate_cb(self, widget): # We create a timeout object to avoid fast lookups on disk when typing. self.timer_id = GObject.timeout_add(500, self._validate, widget.get_child())
Example #24
Source File: assemble_dialog.py From bokken with GNU General Public License v2.0 | 5 votes |
def _update(self, widget, data=None): # This loop makes sure that we only call _find every 500 ms . if self.timer_id: # We destroy the last event source and create another one. GObject.source_remove(self.timer_id) self.timer_id = GObject.timeout_add(500, self._refresh, widget, data)
Example #25
Source File: searchable.py From bokken with GNU General Public License v2.0 | 5 votes |
def _find_cb(self, widget, data): # This loop makes sure that we only call _find every 500 ms . if self.timer_id: # We destroy the last event source and create another one. GObject.source_remove(self.timer_id) self.timer_id = GObject.timeout_add(500, self._find, widget, data)
Example #26
Source File: signals.py From zim-desktop-wiki with GNU General Public License v2.0 | 5 votes |
def __call__(self, *arg, **kwarg): if self.timer_id: GObject.source_remove(self.timer_id) self.timer_id = None def callback(): self.timer_id = None self.cb_func(*arg, **kwarg) return False # destroy timeout self.timer_id = GObject.timeout_add(self.timeout, callback)
Example #27
Source File: bookmarksbar.py From zim-desktop-wiki with GNU General Public License v2.0 | 5 votes |
def blink(self): '''Quickly change an icon to show that bookmark can't be added/changed.''' def change_icon(): '''Function to be called only once.''' self.change_state() return False self.change_state() GObject.timeout_add(300, change_icon)
Example #28
Source File: ClockGramplet.py From addons-source with GNU General Public License v2.0 | 5 votes |
def __init__(self): Gtk.DrawingArea.__init__(self) self.connect("draw", self.on_draw) self.timer = GObject.timeout_add(1000, self.tick)
Example #29
Source File: kano_progress.py From kano-toolset with GNU General Public License v2.0 | 5 votes |
def __init__(self, pulse=True, rate=0.01): Gtk.ProgressBar.__init__(self) self.activity_mode = pulse self.still_working = True self.progress_rate = rate if self.activity_mode: self.pulse() else: self.set_fraction(0.0) GObject.timeout_add(50, self.on_timeout, None)
Example #30
Source File: backend_gtk3.py From Computable with MIT License | 5 votes |
def _timer_start(self): # Need to stop it, otherwise we potentially leak a timer id that will # never be stopped. self._timer_stop() self._timer = GObject.timeout_add(self._interval, self._on_timer)