当前位置: 首页>>代码示例>>Python>>正文


Python GLib.timeout_add方法代码示例

本文整理汇总了Python中gi.repository.GLib.timeout_add方法的典型用法代码示例。如果您正苦于以下问题:Python GLib.timeout_add方法的具体用法?Python GLib.timeout_add怎么用?Python GLib.timeout_add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gi.repository.GLib的用法示例。


在下文中一共展示了GLib.timeout_add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _update_overlay

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import timeout_add [as 别名]
def _update_overlay(self, auto = False):
        ffbmeter_overlay = self.ffbmeter_overlay.get_active()
        wheel_range_overlay = self.get_wheel_range_overlay()
        if ffbmeter_overlay or wheel_range_overlay == 'always' or (wheel_range_overlay == 'auto' and auto):
            if not self.overlay_window.props.visible:
                self.overlay_window.show()
            if not self.ffbmeter_timer and self.overlay_window.props.visible and ffbmeter_overlay:
                GLib.timeout_add(250, self.update_ffbmeter_overlay)
            if ffbmeter_overlay:
                self._ffbmeter_overlay.show()
            else:
                self._ffbmeter_overlay.hide()
            if wheel_range_overlay == 'always' or (wheel_range_overlay == 'auto' and auto):
                self._wheel_range_overlay.show()
            else:
                self._wheel_range_overlay.hide()

        else:
            self.overlay_window.hide() 
开发者ID:berarma,项目名称:oversteer,代码行数:21,代码来源:gtk_ui.py

示例2: _gtk_configure

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import timeout_add [as 别名]
def _gtk_configure(self, widget, event):
        def resize(*args):
            self._resize_timer_id = None
            width, height = self._window.get_size()
            columns = width // self._cell_pixel_width
            rows = height // self._cell_pixel_height
            if self._screen.columns == columns and self._screen.rows == rows:
                return
            self._bridge.resize(columns, rows)

        if not self._screen:
            return
        if event.width == self._pixel_width and \
           event.height == self._pixel_height:
            return
        if self._resize_timer_id is not None:
            GLib.source_remove(self._resize_timer_id)
        self._resize_timer_id = GLib.timeout_add(250, resize) 
开发者ID:neovim,项目名称:python-gui,代码行数:20,代码来源:gtk_ui.py

示例3: on_btn_start_clicked

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import timeout_add [as 别名]
def on_btn_start_clicked(self, _widget):
        """Handle btn_start.clicked event."""
        seconds = int(self.adj_seconds.get_value())
        self.spawn_process.spawn('iperf -s -xS -yC'.split(),
                                 timeout=(seconds + 3),
                                 lines_max=2*len(self.clients))
        for client in self.clients:
            handle = self.clients[client][0]
            # Half time for upload speed and half for download
            self.execute(handle, 'start_benchmark %d' % int(seconds/2))
        self.timeleft = seconds
        self.box_seconds.set_visible(False)
        self.box_countdown.set_visible(True)
        self.btn_start.set_visible(False)
        self.btn_stop.set_visible(True)
        self.lbl_countdown.set_text(_("Benchmark finishing in %d seconds...")
                                    % self.timeleft)
        self.countdown_event = GLib.timeout_add(1000, self.update_countdown) 
开发者ID:epoptes,项目名称:epoptes,代码行数:20,代码来源:benchmark.py

示例4: connect

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import timeout_add [as 别名]
def connect(self):
        """Handle btn_action clicked when it's in the Connect state."""
        self.host = self.ent_host.get_text().strip()
        pid = os.getpid()

        share_terminal = self.cmb_method.get_active() != 0
        if share_terminal:
            cmd = ['xterm', '-e', os.path.dirname(__file__) +
                   '/share-terminal', self.host]
            subprocess.Popen(cmd)
            self.on_btn_close_clicked(None)
            return

        cmd = ['x11vnc', '-q', '-nopw', '-connect_or_exit', self.host,
               '-afteraccept', 'kill -USR1 {}'.format(pid)]
        self.proc = subprocess.Popen(cmd)

        # Set the status as "Connecting"
        if self.retry_timeout_id:
            GLib.source_remove(self.retry_timeout_id)
            self.retry_timeout_id = None
        self.set_state('connecting')

        # Start polling the process every 1 second to see if it's still alive
        GLib.timeout_add(1000, self.poll_process) 
开发者ID:epoptes,项目名称:epoptes,代码行数:27,代码来源:remote_assistance.py

示例5: rebuild

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import timeout_add [as 别名]
def rebuild(self):
        """
        Rebuild.
        """
        if not self.active:
            return # Don't rebuild, we are hidden.
        if self.load < 3: # avoid to load the database twice
            return
        self.total = self.dbstate.db.get_number_of_people()
        self._erase_name_selection()
        active = self.get_active()
        if active != "":
            self.on_draw_ok = -1
            self.people, self.families, self.layers = self.read_data(active)
            self.canvas.queue_draw()
            self.canvas.grab_focus()
            # We need to wait on_draw is called to draw path lines.
            self.on_draw_ok = 0
            GLib.timeout_add(int(200), self.after_on_draw_on_rebuild) 
开发者ID:gramps-project,项目名称:addons-source,代码行数:21,代码来源:QuiltView.py

示例6: show_family_name

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import timeout_add [as 别名]
def show_family_name(self, handle, event):
        """
        Popup menu for node (family).
        """
        if handle:
            family = self.dbstate.db.get_family_from_handle(handle)
        else:
            return False

        if family:
            if not self.timeout:
                self.save_tooltip = handle
                self.scrolledwindow.set_property("has-tooltip", True)
                tooltip = self.get_family_name(handle)
                self.scrolledwindow.set_tooltip_text(tooltip)
                self.timeout = GLib.timeout_add(3*1000, self.remove_tooltip)
            elif handle != self.save_tooltip:
                self.save_tooltip = handle
                GLib.source_remove(self.timeout)
                tooltip = self.get_family_name(handle)
                self.scrolledwindow.set_tooltip_text(tooltip)
                self.timeout = GLib.timeout_add(3*1000, self.remove_tooltip) 
开发者ID:gramps-project,项目名称:addons-source,代码行数:24,代码来源:QuiltView.py

示例7: run

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import timeout_add [as 别名]
def run(self):
            self.loop = GLib.MainLoop()

            if self.config.notifications:
                try:
                    notify2.init("pantalaimon", mainloop=self.loop)
                    self.notifications = True
                except dbus.DBusException:
                    logger.error(
                        "Notifications are enabled but no notification "
                        "server could be found, disabling notifications."
                    )
                    self.notifications = False

            GLib.timeout_add(100, self.message_callback)
            if not self.loop:
                return

            self.loop.run() 
开发者ID:matrix-org,项目名称:pantalaimon,代码行数:21,代码来源:ui.py

示例8: on_touch

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import timeout_add [as 别名]
def on_touch(self, widget, event):
        """Clear mouse connection when touching screen.

        This stops calling the ButtonX bindings when using the touch screen.
        Reasoning: We do not want to e.g. move to the next image when trying to
            zoom in.
        """
        try:
            self._app["window"].disconnect_by_func(self.on_click)
        # Was already disconnected
        except TypeError:
            pass
        if self._timer_id_touch:
            GLib.source_remove(self._timer_id_touch)
        self._timer_id_touch = GLib.timeout_add(5, self._reconnect_click)
        return True 
开发者ID:karlch,项目名称:vimiv,代码行数:18,代码来源:eventhandler.py

示例9: timer

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import timeout_add [as 别名]
def timer(self, name, delay, callback, *data, **kwdata):
		"""
		Runs callback after specified number of seconds. Uses
		GLib.timeout_add_seconds with small wrapping to allow named
		timers to be canceled by reset() call
		"""
		method = GLib.timeout_add_seconds
		if delay < 1 and delay > 0:
			method = GLib.timeout_add
			delay = delay * 1000.0
		if name is None:
			# No wrapping is needed, call GLib directly
			method(delay, callback, *data, **kwdata)
		else:
			if name in self._timers:
				# Cancel old timer
				GLib.source_remove(self._timers[name])
			# Create new one
			self._timers[name] = method(delay, self._callback, name, callback, *data, **kwdata) 
开发者ID:kozec,项目名称:syncthing-gtk,代码行数:21,代码来源:timermanager.py

示例10: enable_all_plots

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import timeout_add [as 别名]
def enable_all_plots(self, *args):
        self.plotcanvas.clear()
        self.set_progress_bar(0.1, "Re-plotting...")

        def worker_task(app_obj):
            percentage = 0.1
            try:
                delta = 0.9 / len(self.collection.get_list())
            except ZeroDivisionError:
                GLib.timeout_add(300, lambda: app_obj.set_progress_bar(0.0, ""))
                return
            for obj in self.collection.get_list():
                obj.options['plot'] = True
                obj.plot()
                percentage += delta
                GLib.idle_add(lambda: app_obj.set_progress_bar(percentage, "Re-plotting..."))

            GLib.idle_add(app_obj.plotcanvas.auto_adjust_axes)
            GLib.timeout_add(300, lambda: app_obj.set_progress_bar(0.0, ""))

        # Send to worker
        self.worker.add_task(worker_task, [self]) 
开发者ID:Denvi,项目名称:FlatCAM,代码行数:24,代码来源:FlatCAMApp.py

示例11: on_update_plot

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import timeout_add [as 别名]
def on_update_plot(self, widget):
        """
        Callback for button on form for all kinds of objects.
        Re-plots the current object only.

        :param widget: The widget from which this was called. Ignored.
        :return: None
        """

        obj = self.collection.get_active()
        obj.read_form()

        self.set_progress_bar(0.5, "Plotting...")

        def thread_func(app_obj):
            assert isinstance(app_obj, App)
            obj.plot()
            GLib.timeout_add(300, lambda: app_obj.set_progress_bar(0.0, "Idle"))

        # Send to worker
        self.worker.add_task(thread_func, [self]) 
开发者ID:Denvi,项目名称:FlatCAM,代码行数:23,代码来源:FlatCAMApp.py

示例12: on_pane_event

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import timeout_add [as 别名]
def on_pane_event(self, widget, evt):
        """ Signal handler for gtk.paned events.

        This function allows one to delay drawing events when resizing, and to speed up redrawing when
        moving the middle pane is done (which happens at the end of a mouse resize)

        Args:
            widget (:class:`~Gtk.Widget`):  the widget in which the event occurred (ignored)
            evt (:class:`~Gdk.Event`):  the event that occurred
        """
        if type(evt) == Gdk.EventButton and evt.type == Gdk.EventType.BUTTON_RELEASE:
            self.redraw_panes()
        elif type(evt) == GObject.GParamSpec and evt.name == "position":
            self.resize_panes = True
            if self.redraw_timeout:
                GLib.Source.remove(self.redraw_timeout)
            self.redraw_timeout = GLib.timeout_add(200, self.redraw_panes)


    ############################################################################
    ############################  Program lifetime  ############################
    ############################################################################ 
开发者ID:Cimbali,项目名称:pympress,代码行数:24,代码来源:ui.py

示例13: state_loop

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import timeout_add [as 别名]
def state_loop(self, scroll_scale=None, delay=16):  # 16ms ~ 60hz
        # Remove any pending callbacks
        if self.timeout_id:
            GLib.source_remove(self.timeout_id)
            self.timeout_id = None

        # Set scroll scale if specified, and the state is not dirty
        if not self.state_discard_read and scroll_scale not in (None, self.scroll_scale):
            self.scroll_scale = scroll_scale
            if self.scroll_scale != -1:
                self.emit("scroll-scale-changed", self.scroll_scale)
        self.state_discard_read = False

        # Handle the current state
        if not self.state_loaded or self.state_load_failed or self.state_waiting:
            return
        elif self.state_dirty or delay == 0:
            self.sync_scroll_scale(self.scroll_scale, self.state_dirty)
            self.state_dirty = False
        else:
            self.timeout_id = GLib.timeout_add(delay, self.state_loop, None, 0) 
开发者ID:ApostropheEditor,项目名称:Apostrophe,代码行数:23,代码来源:preview_web_view.py

示例14: play

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import timeout_add [as 别名]
def play(self):
        if self.uri.endswith(".MP4"):
            self.is_playing = True
        else:
            self.is_playing = False
        cli.log.info(_("play"))
        self.player.set_state(Gst.State.PLAYING)

        # starting up a timer to check on the current playback value
        GLib.timeout_add(1000, self.update_slider) 
开发者ID:encarsia,项目名称:gpt,代码行数:12,代码来源:modules.py

示例15: delayed_signal

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import timeout_add [as 别名]
def delayed_signal(delay=500):
	"""
	A decorator to delay the execution of a signal handler to aggregate emission
	into a single event. This can for example be used to run a handler when a
	:py:class:`Gtk.Entry` widget's ``changed`` signal is emitted but not after
	every single key press meaning the handler can perform network operations to
	validate or otherwise process input.

	.. note::
		The decorated function **must** be a method. The wrapper installed by
		this decorator will automatically add an attribute to the class to track
		invoked instances to ensure the timeout is respected.

	.. versionadded:: 1.14.0

	:param int delay: The delay in milliseconds from the original emission
		before the handler should be executed.
	"""
	def decorator(function):
		src_name = '__delayed_source_' + function.__name__
		@functools.wraps(function)
		def wrapped(self, *args, **kwargs):
			def new_function(self, *args, **kwargs):
				setattr(self, src_name, None)
				return function(self, *args, **kwargs)
			src = getattr(self, src_name, None)
			if src is not None:
				return
			src = GLib.timeout_add(delay, new_function, self, *args, **kwargs)
			setattr(self, src_name, src)
		return wrapped
	return decorator 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:34,代码来源:gui_utilities.py


注:本文中的gi.repository.GLib.timeout_add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。