Python gi.repository.GObject.idle_add() Examples
The following are 30
code examples of gi.repository.GObject.idle_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: gtk.py From encompass with GNU General Public License v3.0 | 6 votes |
def restore_wallet(self, wallet): dialog = Gtk.MessageDialog( parent = None, flags = Gtk.DialogFlags.MODAL, buttons = Gtk.ButtonsType.CANCEL, message_format = "Please wait..." ) dialog.show() def recover_thread( wallet, dialog ): wallet.restore(lambda x:x) GObject.idle_add( dialog.destroy ) thread.start_new_thread( recover_thread, ( wallet, dialog ) ) r = dialog.run() dialog.destroy() if r==Gtk.ResponseType.CANCEL: return False if not wallet.is_found(): show_message("No transactions found for this seed") return True
Example #2
Source File: utils.py From rednotebook with GNU General Public License v2.0 | 6 votes |
def _check_new_version(journal, current_version, startup): current_version = StrictVersion(current_version) new_version = get_new_version_number() if new_version is not None: newer_version_available = new_version > current_version else: logging.error("New version info could not be read") new_version = _("unknown") newer_version_available = None logging.info( "Current version: %s, latest version: %s, newer: %s" % (current_version, new_version, newer_version_available) ) if newer_version_available or not startup: GObject.idle_add( _show_update_dialog, journal, current_version, new_version, startup )
Example #3
Source File: bluetooth_config.py From kano-settings with GNU General Public License v2.0 | 6 votes |
def populate(self): def _end_populate(): self.unset_loading() @queue_cb(callback=_end_populate, gtk=True) def _do_populate(devices): if not devices: logger.info("No devices") GObject.idle_add(self.set_no_devices_nearby) for idx, device in enumerate(devices): logger.info("Adding device {}".format(device)) GObject.idle_add(self.add_device, device, idx) if not is_bluetooth_available(): logger.info("No adapter") self.set_no_adapter_available() return self.set_loading() device_scan(_do_populate)
Example #4
Source File: main.py From Dindo-Bot with MIT License | 6 votes |
def wait_for_click(self, callback, game_location=None): # wait for click tools.wait_for_mouse_event('left_down') # get mouse position & screen size x, y = tools.get_mouse_position() width, height = tools.get_screen_size() # get pixel color color = tools.get_pixel_color(x, y) # adjust location to game window if game_location is not None: # get game area location game_x, game_y, game_width, game_height = game_location #print('x: %d, y: %d, game_x: %d, game_y: %d, game_width: %d, game_height: %d' % (x, y, game_x, game_y, game_width, game_height)) # scale to game area if tools.position_is_inside_bounds(x, y, game_x, game_y, game_width, game_height): # position is inside game area, so we fit x & y to it x = x - game_x y = y - game_y width = game_width height = game_height # execute callback GObject.idle_add(callback, (x, y, width, height, color))
Example #5
Source File: cric_indicator.py From cricket-score-applet with GNU General Public License v3.0 | 6 votes |
def contract_submenu(self, match_item): match_item['gtk_check'].set_active(False) match_item['gtk_description'].hide() match_item['gtk_separator_2'].hide() match_item['gtk_scorecard'].hide() match_item['gtk_separator_3'].hide() match_item['gtk_commentary'].hide() match_item['gtk_separator_4'].hide() match_item['last_ball'] = DEFAULT_ICON # set to default match_item['status'] = "" match_item['label_scoreline'] = "" # force update in current cycle self.update_menu_icon(match_item) #GObject.idle_add(match_item['gtk_menu'].set_image,Gtk.Image.new_from_icon_name(ICON_PREFIX + match_item['last_ball'], Gtk.IconSize.BUTTON)) if match_item['id'] == self.label_match_id: self.set_indicator_icon(match_item['last_ball']) self.set_indicator_label(match_item['gtk_menu'].get_label())
Example #6
Source File: ipc.py From zim-desktop-wiki with GNU General Public License v2.0 | 6 votes |
def _do_accept(listener, handler, *a): try: conn = listener.accept() args = conn.recv() logger.debug('Recieved remote call: %r', args) if args == 'CLOSE': conn.send('OK') conn.close() return False else: assert isinstance(args, (list, tuple)) # Throw back into the main thread -- assuming gtk main running def callback(): handler(*args) return False # delete signal GObject.idle_add(callback) conn.send('OK') conn.close() except: logger.exception('Error while handling incoming connection') return True
Example #7
Source File: job.py From Dindo-Bot with MIT License | 5 votes |
def set_pod(self, percentage): if self.podbar_enabled: self.debug('Update PodBar (percentage: {}%)'.format(percentage)) # set podbar value GObject.idle_add(self.parent.podbar.set_fraction, percentage / 100.0)
Example #8
Source File: base.py From Dindo-Bot with MIT License | 5 votes |
def reset(self): GObject.idle_add(self.parent.reset_buttons)
Example #9
Source File: base.py From Dindo-Bot with MIT License | 5 votes |
def debug(self, text, level=DebugLevel.Normal): GObject.idle_add(self.parent.debug, text, level) self.slow_down()
Example #10
Source File: job.py From Dindo-Bot with MIT License | 5 votes |
def remove_from_minimap(self, index): if self.minimap_enabled: self.debug('Remove point from MiniMap (index: %d)' % index) GObject.idle_add(self.parent.minimap.remove_point, index)
Example #11
Source File: job.py From Dindo-Bot with MIT License | 5 votes |
def update_minimap(self, points, points_name=None, points_color=None): if self.minimap_enabled: self.debug('Update MiniMap') # clear minimap GObject.idle_add(self.parent.minimap.clear) # update minimap GObject.idle_add(self.parent.minimap.add_points, points, points_name, points_color)
Example #12
Source File: decimalentry.py From amir with GNU General Public License v3.0 | 5 votes |
def insert_cb(self, widget, text, length, position): # if you don't do this, garbage comes in with text text = text[:length] pos = widget.get_position() # stop default emission widget.emit_stop_by_name("insert_text") GObject.idle_add(self.insert, widget, text, pos)
Example #13
Source File: game.py From Dindo-Bot with MIT License | 5 votes |
def monitor_internet_state(self, timeout=30): elapsed_time = 0 reported = False while elapsed_time < timeout: # check for pause or suspend self.pause_event.wait() if self.suspend: return # get internet state state = tools.internet_on() if state: if reported: GObject.idle_add(self.parent.set_internet_state, state) return else: # print state self.debug(tools.print_internet_state(state), DebugLevel.High) if not reported: GObject.idle_add(self.parent.set_internet_state, state) reported = True # wait 1 second, before recheck time.sleep(1) elapsed_time += 1 # if timeout reached if elapsed_time == timeout: self.pause() self.log('Unable to connect to the internet', LogType.Error)
Example #14
Source File: debian.py From AstroBox with GNU Affero General Public License v3.0 | 5 votes |
def run(self): self._stopped = False self._loop = GObject.MainLoop() self._propertiesListener = NetworkManager.NetworkManager.OnPropertiesChanged(self.propertiesChanged) self._stateChangeListener = NetworkManager.NetworkManager.OnStateChanged(self.globalStateChanged) connectionState = NetworkManager.NetworkManager.State logger.info('Network Manager reports state: *[%s]*' % NetworkManager.const('state', connectionState)) if connectionState == NetworkManager.NM_STATE_CONNECTED_GLOBAL: self._setOnline(True) #d = self.getActiveConnectionDevice() #if d: # self._devicePropertiesListener = d.Dhcp4Config.connect_to_signal('PropertiesChanged', self.activeDeviceConfigChanged) # self._currentIpv4Address = d.Ip4Address # self._activeDevice = d # self._online = True # logger.info('Active Connection found at %s (%s)' % (d.IpInterface, d.Ip4Address)) while not self._stopped: try: self._loop.run() except KeyboardInterrupt: #kill the main process too from octoprint import astrobox astrobox.stop() except DBusException as e: #GObject.idle_add(logger.error, 'Exception during NetworkManagerEvents: %s' % e) logger.error('Exception during NetworkManagerEvents: %s' % e) finally: self.stop()
Example #15
Source File: debian.py From AstroBox with GNU Affero General Public License v3.0 | 5 votes |
def idle_add_decorator(func): def callback(nm, interface, signal, *args): #GObject.idle_add(func, *args) func(*args) return callback
Example #16
Source File: progress.py From pyWinUSB with MIT License | 5 votes |
def on_done(self, err=None): if err is not None: GObject.idle_add(self.show_warning, "Error!", err, Gtk.MessageType.WARNING) else: GObject.idle_add(self.show_warning, "Copying done!", "You can eject device!") self.destroy()
Example #17
Source File: progress.py From pyWinUSB with MIT License | 5 votes |
def on_progress(self, total, current, file): GObject.idle_add( self.update_progress , re.search("pyWinUSB\/\w{40}\/source\/(.*)", file).group(1) , current / total )
Example #18
Source File: gtkui.py From alienfx with GNU General Public License v3.0 | 5 votes |
def on_action_apply_activate(self, widget): """ Handler for when the "Apply Theme" action is triggered.""" self.builder.get_object("toolbar").set_sensitive(False) statusbar = self.builder.get_object("statusbar") self.context_id = statusbar.get_context_id("Apply") statusbar.push(self.context_id, "Applying theme...") spinner = self.builder.get_object("spinner") spinner.show() spinner.start() self.set_theme_done = False GObject.idle_add(self.set_theme_done_cb) self.set_theme_thread = threading.Thread(target=self.set_theme) self.set_theme_thread.start()
Example #19
Source File: base.py From Dindo-Bot with MIT License | 5 votes |
def pause(self): self._pause() GObject.idle_add(self.parent.set_buttons_to_paused)
Example #20
Source File: numberentry.py From amir with GNU General Public License v3.0 | 5 votes |
def insert_cb(self, widget, text, length, position): # if you don't do this, garbage comes in with text text = text[:length] pos = widget.get_position() # stop default emission widget.emit_stop_by_name("insert_text") GObject.idle_add(self.insert, widget, text, pos)
Example #21
Source File: progress.py From pyWinUSB with MIT License | 5 votes |
def on_status(self, status): GObject.idle_add(self.update_status, status)
Example #22
Source File: connection.py From runsqlrun with MIT License | 5 votes |
def run(self): while self.keep_running: if self._connect_request: try: if not self.open(): continue except Exception: pass self._connect_request = False if not self.queries: time.sleep(.05) continue query = self.queries.pop() try: if not self.open(): continue except Exception as err: query.finished = True query.failed = True query.error = str(err).strip() GObject.idle_add(query.emit, 'finished') # Reset session password self._session_pwd = None continue GObject.idle_add(query.emit, 'started') query.start_time = time.time() query.pending = False try: self.db.execute(query) except Exception as err: query.failed = True query.error = str(err) query.execution_duration = time.time() - query.start_time query.finished = True GObject.idle_add(query.emit, 'finished') if self.db is not None: self.db.close() self._close_tunnel() self.db = None self.emit('state-changed')
Example #23
Source File: __init__.py From zim-desktop-wiki with GNU General Public License v2.0 | 5 votes |
def start(self): if not self.running: my_iter = iter(self.on_idle_iter()) GObject.idle_add(lambda: next(my_iter, False), priority=GObject.PRIORITY_LOW) self.running = True
Example #24
Source File: operations.py From zim-desktop-wiki with GNU General Public License v2.0 | 5 votes |
def run_on_idle(self): '''Start the operation by setting up the main loop event handler. May raise L{NotebookOperationOngoing} if another operation is already ongoing. ''' assert GObject, "No mainloop available to run this operation" if self.notebook._operation_check == self: raise AssertionError('Already running') else: self.notebook._operation_check() # can raise self.notebook._operation_check = self # start blocking GObject.idle_add(self._start) # ensure start happens in main thread
Example #25
Source File: operations.py From zim-desktop-wiki with GNU General Public License v2.0 | 5 votes |
def _start(self): my_iter = iter(self) GObject.idle_add(lambda: next(my_iter, False), priority=GObject.PRIORITY_LOW) return False # run once
Example #26
Source File: __init__.py From zim-desktop-wiki with GNU General Public License v2.0 | 5 votes |
def on_get_iter(self, treepath): '''Returns an MyTreeIter for a gtk TreePath or None''' # Schedule a flush with some timeout to try to take advantage # of known cache for repeated requests. Cache can grow very fast # on scroll, so don't make the time constant to large. if not self._flush_scheduled: def idle_add(): GObject.idle_add(self.flush_cache) return False # delete timeout GObject.timeout_add(500, idle_add) self._flush_scheduled = True return self.get_mytreeiter(treepath)
Example #27
Source File: clouds.py From rednotebook with GNU General Public License v2.0 | 5 votes |
def update(self, force_update=False): """Public method that calls the private "_update".""" if self.journal.frame is None: return # Do not update the cloud with words as it requires a lot of searching if not force_update: return GObject.idle_add(self._update)
Example #28
Source File: main_window.py From rednotebook with GNU General Public License v2.0 | 5 votes |
def on_edit_button_clicked(self, button): # The day's text is already in the editor. self.change_mode(preview=False) # Select (not only highlight) previously selected text by giving focus # to the day editor. GObject.idle_add(self.day_text_field.day_text_view.grab_focus)
Example #29
Source File: main_window.py From rednotebook with GNU General Public License v2.0 | 5 votes |
def show_day(self, new_day): # Show new day self.day = new_day buf = self._get_buffer_for_day(new_day) self.replace_buffer(buf) self.day_text_view.grab_focus() if self.search_text: # If a search is currently made, scroll to the text and return. GObject.idle_add(self.scroll_to_text, self.search_text) GObject.idle_add(self.highlight, self.search_text) return
Example #30
Source File: search.py From rednotebook with GNU General Public License v2.0 | 5 votes |
def search(self, search_text): tags = [] queries = [] for part in search_text.split(): if part.startswith("#"): tags.append(part.lstrip("#").lower()) else: queries.append(part) search_text = " ".join(queries) # Highlight all occurences in the current day's text self.main_window.highlight_text(search_text) # Scroll to query. if search_text: GObject.idle_add( self.main_window.day_text_field.scroll_to_text, search_text ) self.main_window.search_tree_view.update_data(search_text, tags) # Without the following, showing the search results sometimes lets the # search entry lose focus and search phrases are added to a day's text. if not self.entry.has_focus(): self.entry.grab_focus()