Python gobject.timeout_add() Examples
The following are 30
code examples of 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
gobject
, or try the search function
.
Example #1
Source File: __init__.py From launcher with GNU General Public License v3.0 | 6 votes |
def StartDownload(self,url,dst_dir): if validators.url(url) and os.path.isdir(dst_dir): self._URL = url self._DST_DIR = dst_dir else: self._Screen._MsgBox.SetText("Invaid") self._Screen._MsgBox.Draw() self._Screen.SwapAndShow() return self._Downloader = Download(url,dst_dir,None) if self._MD5 != None: if len(self._MD5) == 32: self._Downloader.add_hash_verification('md5' ,self._MD5) ## hashlib provide algorithms self._Downloader.start() self._DownloaderTimer = gobject.timeout_add(100, self.GObjectUpdateProcessInterval)
Example #2
Source File: wifi_list.py From launcher with GNU General Public License v3.0 | 6 votes |
def UpdateStatus(self): print("UpdateStatus") wireless_connecting = self._Wireless.CheckIfWirelessConnecting() fast = not self._Daemon.NeedsExternalCalls() self._Connecting = wireless_connecting if self._Connecting: gobject.timeout_add(250,self.SetConnectingStatus,fast) else: if not fast: iwconfig = self._Wireless.GetIwconfig() else: iwconfig = '' if self.CheckForWireless(iwconfig,self._Wireless.GetWirelessIP(''),None): return True else: print("Not Connected") return True
Example #3
Source File: gnome_connection_manager.py From gnome-connection-manager with GNU General Public License v3.0 | 6 votes |
def find_word(self, backwards=False): pos=-1 if backwards: lst = range(0, self.search['index']) lst.reverse() lst.extend(reversed(range(self.search['index'], len(self.search['lines'])))) else: lst = range(self.search['index'], len(self.search['lines'])) lst.extend(range(0, self.search['index'])) for i in lst: pos = self.search['lines'][i].find(self.search['word']) if pos != -1: self.search['index'] = i if backwards else i + 1 #print 'found at line %d column %d, index=%d' % (i, pos, self.search['index']) gobject.timeout_add(0, lambda: self.search['terminal'].get_adjustment().set_value(i)) self.search['terminal'].queue_draw() break if pos==-1: self.search['index'] = len(self.search['lines']) if backwards else 0
Example #4
Source File: __init__.py From launcher with GNU General Public License v3.0 | 6 votes |
def OnLoadCb(self): self._Scrolled = 0 self._PosY = 0 self._DrawOnce = False #sync print("OnLoadCb") if self._MyStack.Length() == 1: self._FootMsg[2] = "Remove" self._FootMsg[1] = "Update" else: self._FootMsg[2] = "Remove" self._FootMsg[1] = "Preview" self._GobjTimer = gobject.timeout_add(500, self.GObjectUpdateProcessInterval) self.SyncList()
Example #5
Source File: gtk2reactor.py From python-for-android with Apache License 2.0 | 6 votes |
def doIteration(self, delay): # flush some pending events, return if there was something to do # don't use the usual "while self.context.pending(): self.context.iteration()" # idiom because lots of IO (in particular test_tcp's # ProperlyCloseFilesTestCase) can keep us from ever exiting. log.msg(channel='system', event='iteration', reactor=self) if self.__pending(): self.__iteration(0) return # nothing to do, must delay if delay == 0: return # shouldn't delay, so just return self.doIterationTimer = gobject.timeout_add(int(delay * 1000), self.doIterationTimeout) # This will either wake up from IO or from a timeout. self.__iteration(1) # block # note: with the .simulate timer below, delays > 0.1 will always be # woken up by the .simulate timer if self.doIterationTimer: # if woken by IO, need to cancel the timer gobject.source_remove(self.doIterationTimer) self.doIterationTimer = None
Example #6
Source File: test_time.py From learn_python3_spider with MIT License | 6 votes |
def test_timeout_add(self): """ A L{reactor.callLater<twisted.internet.interfaces.IReactorTime.callLater>} call scheduled from a C{gobject.timeout_add} call is run on time. """ import gobject reactor = self.buildReactor() result = [] def gschedule(): reactor.callLater(0, callback) return 0 def callback(): result.append(True) reactor.stop() reactor.callWhenRunning(gobject.timeout_add, 10, gschedule) self.runReactor(reactor, 5) self.assertEqual(result, [True])
Example #7
Source File: download_process_page.py From launcher with GNU General Public License v3.0 | 6 votes |
def StartDownload(self,url,dst_dir): if is_wifi_connected_now() == False: return if validators.url(url) and os.path.isdir(dst_dir): self._URL = url self._DST_DIR = dst_dir else: self._Screen._MsgBox.SetText("Invaid") self._Screen._MsgBox.Draw() self._Screen.SwapAndShow() print("url or dst dir error") return self._Downloader = Download(url,dst_dir,None) self._Downloader.start() self._DownloaderTimer = gobject.timeout_add(200, self.GObjectUpdateProcessInterval)
Example #8
Source File: gtk2reactor.py From BitTorrent with GNU General Public License v3.0 | 6 votes |
def doIteration(self, delay): # flush some pending events, return if there was something to do # don't use the usual "while self.context.pending(): self.context.iteration()" # idiom because lots of IO (in particular test_tcp's # ProperlyCloseFilesTestCase) can keep us from ever exiting. log.msg(channel='system', event='iteration', reactor=self) if self.__pending(): self.__iteration(0) return # nothing to do, must delay if delay == 0: return # shouldn't delay, so just return self.doIterationTimer = gobject.timeout_add(int(delay * 1000), self.doIterationTimeout) # This will either wake up from IO or from a timeout. self.__iteration(1) # block # note: with the .simulate timer below, delays > 0.1 will always be # woken up by the .simulate timer if self.doIterationTimer: # if woken by IO, need to cancel the timer gobject.source_remove(self.doIterationTimer) self.doIterationTimer = None
Example #9
Source File: gnome_connection_manager.py From gnome-connection-manager with GNU General Public License v3.0 | 5 votes |
def run(self): try: import urllib, socket socket.setdefaulttimeout(5) web = urllib.urlopen('http://kuthulu.com/gcm/_current.html') if web.getcode()==200: new_version = web.readline().strip() if len(new_version)>0 and new_version != app_version: self.tag = gobject.timeout_add(0, self.msg, "%s\n\nVERSION: %s" % (_("Hay una nueva version disponible en http://kuthulu.com/gcm/?module=download"), new_version), self.parent.get_widget("wMain")) except: pass #-- main {
Example #10
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 #11
Source File: gtk-example-camera.py From SimpleCV2 with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self): super(app, self).__init__() self.set_position(gtk.WIN_POS_CENTER) self.set_title("Edge Threshold Adjuster") self.set_decorated(True) self.set_has_frame(False) self.set_resizable(False) self.set_default_size(self.window_width,self.window_height) self.connect("destroy", gtk.main_quit) vbox = gtk.VBox(spacing=4) #Setup the slider bar scale = gtk.HScale() scale.set_range(self.min_threshold, self.max_threshold) scale.set_size_request(500, 25) scale.set_value((self.max_threshold + self.min_threshold) / 2) scale.connect("value-changed", self.update_threshold) vbox.add(scale) #Setup the information label info = gtk.Label() info.set_label("Move the slider to adjust the edge detection threshold") vbox.add(info) #Add the image to the display new_image = self.process_image() converted_image = gtk.gdk.pixbuf_new_from_array(new_image, gtk.gdk.COLORSPACE_RGB, 8) image = gtk.Image() image.set_from_pixbuf(converted_image) image.show() vbox.add(image) gobject.timeout_add(self.refresh_rate, self.refresh) self.current_image = image self.add(vbox) self.show_all()
Example #12
Source File: invocation.py From gimp-plugin-export-layers with GNU General Public License v3.0 | 5 votes |
def timeout_add_strict(interval, callback, *callback_args, **callback_kwargs): """ This is a wrapper for `gobject.timeout_add()`, which calls the specified callback at regular intervals (in milliseconds). Additionally, if the same callback is called again before the timeout, the first invocation will be canceled. If different functions are called before the timeout, they will all be invoked normally. This function also supports keyword arguments to the callback. """ global _timer_ids def _callback_wrapper(callback_args, callback_kwargs): retval = callback(*callback_args, **callback_kwargs) if callback in _timer_ids: del _timer_ids[callback] return retval timeout_remove_strict(callback) _timer_ids[callback] = timeout_add( interval, _callback_wrapper, callback_args, callback_kwargs) return _timer_ids[callback]
Example #13
Source File: xdot.py From EasY_HaCk with Apache License 2.0 | 5 votes |
def start(self): self.timeout_id = gobject.timeout_add(int(self.step * 1000), self.tick)
Example #14
Source File: xdot.py From EasY_HaCk with Apache License 2.0 | 5 votes |
def __init__(self): gtk.DrawingArea.__init__(self) self.graph = Graph() self.openfilename = None self.set_flags(gtk.CAN_FOCUS) self.add_events(gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK) self.connect("button-press-event", self.on_area_button_press) self.connect("button-release-event", self.on_area_button_release) self.add_events(gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.POINTER_MOTION_HINT_MASK | gtk.gdk.BUTTON_RELEASE_MASK) self.connect("motion-notify-event", self.on_area_motion_notify) self.connect("scroll-event", self.on_area_scroll_event) self.connect("size-allocate", self.on_area_size_allocate) self.connect('key-press-event', self.on_key_press_event) self.last_mtime = None gobject.timeout_add(1000, self.update) self.x, self.y = 0.0, 0.0 self.zoom_ratio = 1.0 self.zoom_to_fit_on_resize = False self.animation = NoAnimation(self) self.drag_action = NullAction(self) self.presstime = None self.highlight = None
Example #15
Source File: util.py From tapas with GNU General Public License v2.0 | 5 votes |
def start(self): #debug(1, "%s start", self) self.running = True #self.calc_iteration_id = gobject.timeout_add(int(self.period*1000), # self.calc_iteration) reactor.callLater(self.period, self.calc_iteration)
Example #16
Source File: gtk2reactor.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def simulate(self): """Run simulation loops and reschedule callbacks. """ global _simtag if _simtag is not None: gobject.source_remove(_simtag) self.runUntilCurrent() timeout = min(self.timeout(), 0.1) if timeout is None: timeout = 0.1 # grumble _simtag = gobject.timeout_add(int(timeout * 1010), self.simulate)
Example #17
Source File: backend_gtk.py From twitter-stock-recommendation with MIT License | 5 votes |
def _on_timer(self): TimerBase._on_timer(self) # Gtk timeout_add() requires that the callback returns True if it # is to be called again. if len(self.callbacks) > 0 and not self._single: return True else: self._timer = None return False
Example #18
Source File: backend_gtk.py From twitter-stock-recommendation 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)
Example #19
Source File: invocation.py From gimp-plugin-export-layers with GNU General Public License v3.0 | 5 votes |
def timeout_add(interval, callback, *callback_args): """ This is a thin wrapper of `gobject.timeout_add()` that "fixes" the function failing to work on Windows on GIMP 2.10 by setting the interval to zero. """ if os.name == "nt" and ((2, 10, 0) <= gimp.version < (2, 10, 6)): return gobject.timeout_add(0, callback, *callback_args) else: return gobject.timeout_add(interval, callback, *callback_args)
Example #20
Source File: xdot.py From POC-EXP with GNU General Public License v3.0 | 5 votes |
def __init__(self): gtk.DrawingArea.__init__(self) self.graph = Graph() self.openfilename = None self.set_flags(gtk.CAN_FOCUS) self.add_events(gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK) self.connect("button-press-event", self.on_area_button_press) self.connect("button-release-event", self.on_area_button_release) self.add_events(gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.POINTER_MOTION_HINT_MASK | gtk.gdk.BUTTON_RELEASE_MASK) self.connect("motion-notify-event", self.on_area_motion_notify) self.connect("scroll-event", self.on_area_scroll_event) self.connect("size-allocate", self.on_area_size_allocate) self.connect('key-press-event', self.on_key_press_event) self.last_mtime = None gobject.timeout_add(1000, self.update) self.x, self.y = 0.0, 0.0 self.zoom_ratio = 1.0 self.zoom_to_fit_on_resize = False self.animation = NoAnimation(self) self.drag_action = NullAction(self) self.presstime = None self.highlight = None
Example #21
Source File: xdot.py From POC-EXP with GNU General Public License v3.0 | 5 votes |
def start(self): self.timeout_id = gobject.timeout_add(int(self.step * 1000), self.tick)
Example #22
Source File: gtk2reactor.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def simulate(self): """Run simulation loops and reschedule callbacks. """ global _simtag if _simtag is not None: gobject.source_remove(_simtag) self.iterate() timeout = min(self.timeout(), 0.1) if timeout is None: timeout = 0.1 # grumble _simtag = gobject.timeout_add(int(timeout * 1010), self.simulate)
Example #23
Source File: core.py From ns3-ecn-sharp with GNU General Public License v2.0 | 5 votes |
def _start_update_timer(self): if self._update_timeout_id is not None: gobject.source_remove(self._update_timeout_id) #print "start_update_timer" self._update_timeout_id = gobject.timeout_add(int(SAMPLE_PERIOD/min(self.speed, 1)*1e3), self.update_view_timeout, priority=PRIORITY_UPDATE_VIEW)
Example #24
Source File: gtk2reactor.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def run(self, installSignalHandlers=1): self.startRunning(installSignalHandlers=installSignalHandlers) gobject.timeout_add(0, self.simulate) self.__run()
Example #25
Source File: gtk2reactor.py From python-for-android with Apache License 2.0 | 5 votes |
def simulate(self): """ Run simulation loops and reschedule callbacks. """ if self._simtag is not None: gobject.source_remove(self._simtag) self.iterate() timeout = min(self.timeout(), 0.1) if timeout is None: timeout = 0.1 # grumble self._simtag = gobject.timeout_add(int(timeout * 1010), self.simulate)
Example #26
Source File: gtk2reactor.py From python-for-android with Apache License 2.0 | 5 votes |
def run(self, installSignalHandlers=1): import gtk self.startRunning(installSignalHandlers=installSignalHandlers) gobject.timeout_add(0, self.simulate) # mainloop is deprecated in newer versions if hasattr(gtk, 'main'): gtk.main() else: gtk.mainloop()
Example #27
Source File: gtk2reactor.py From python-for-android with Apache License 2.0 | 5 votes |
def simulate(self): """ Run simulation loops and reschedule callbacks. """ if self._simtag is not None: gobject.source_remove(self._simtag) self.runUntilCurrent() timeout = min(self.timeout(), 0.1) if timeout is None: timeout = 0.1 # grumble self._simtag = gobject.timeout_add(int(timeout * 1010), self.simulate)
Example #28
Source File: gtk2reactor.py From python-for-android with Apache License 2.0 | 5 votes |
def run(self, installSignalHandlers=1): self.startRunning(installSignalHandlers=installSignalHandlers) gobject.timeout_add(0, self.simulate) if self._started: self.__run()
Example #29
Source File: core.py From CRE-NS3 with GNU General Public License v2.0 | 5 votes |
def start(self): self.scan_topology() self.window.connect("delete-event", self._quit) #self._start_update_timer() gobject.timeout_add(200, self.autoscale_view) self.simulation.start() try: __IPYTHON__ except NameError: pass else: self._monkey_patch_ipython() gtk.main()
Example #30
Source File: core.py From CRE-NS3 with GNU General Public License v2.0 | 5 votes |
def _start_update_timer(self): if self._update_timeout_id is not None: gobject.source_remove(self._update_timeout_id) #print "start_update_timer" self._update_timeout_id = gobject.timeout_add(int(SAMPLE_PERIOD/min(self.speed, 1)*1e3), self.update_view_timeout, priority=PRIORITY_UPDATE_VIEW)