當前位置: 首頁>>代碼示例>>Python>>正文


Python GLib.timeout_add_seconds方法代碼示例

本文整理匯總了Python中gi.repository.GLib.timeout_add_seconds方法的典型用法代碼示例。如果您正苦於以下問題:Python GLib.timeout_add_seconds方法的具體用法?Python GLib.timeout_add_seconds怎麽用?Python GLib.timeout_add_seconds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gi.repository.GLib的用法示例。


在下文中一共展示了GLib.timeout_add_seconds方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: num_append

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import timeout_add_seconds [as 別名]
def num_append(self, num, remove_by_timeout=True):
        """Add a new char to num_str.

        Args:
            num: The number to append to the string.
            remove_by_timeout: If True, add a timeout to clear the num_str.
        """
        # Remove old timers if we have new numbers
        if self._timer_id:
            GLib.source_remove(self._timer_id)
        self._timer_id = GLib.timeout_add_seconds(1, self.num_clear)
        self._num_str += num
        self._convert_trailing_zeros()
        # Write number to log file in debug mode
        if self._app.debug:
            self._app["log"].write_message("number", num + "->" + self._num_str)
        self._app["statusbar"].update_info() 
開發者ID:karlch,項目名稱:vimiv,代碼行數:19,代碼來源:eventhandler.py

示例2: _peek

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import timeout_add_seconds [as 別名]
def _peek(self):
		if self._closed:
			return False
		# Check if there is anything to read and read if available
		(read, nAvail, nMessage) = win32pipe.PeekNamedPipe(self._osfhandle, 0)
		if nAvail >= self._buffer_size:
			data = self._pipe.read(self._buffer_size)
			self._buffer += data
		# If there is read_async callback and buffer has some data,
		# send them right away
		if not self._waits_for_read is None and len(self._buffer) > 0:
			r = WinPopenReader.Results(self._buffer)
			self._buffer = ""
			callback, data = self._waits_for_read
			self._waits_for_read = None
			callback(self, r, *data)
			GLib.idle_add(self._peek)
			return False
		GLib.timeout_add_seconds(1, self._peek)
		return False 
開發者ID:kozec,項目名稱:syncthing-gtk,代碼行數:22,代碼來源:windows.py

示例3: timer

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import timeout_add_seconds [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

示例4: edit_playlist

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import timeout_add_seconds [as 別名]
def edit_playlist(self, leaf_iter):
        """
           edit the playlist
        :param leaf_iter: treestore iter
        :return:
        """
        print("edit_playlist")
        self.text_renderer.props.editable = True
        path = self.treestore.get_path(leaf_iter)
        path = self.treestore_filter.convert_child_path_to_path(path)
        print(path)
        self.grab_focus()

        def delayed(*args):
            self.set_cursor_on_cell(path,
                                    self.tree_column, self.text_renderer, True)

        GLib.timeout_add_seconds(1, delayed, None) 
開發者ID:fossfreedom,項目名稱:alternative-toolbar,代碼行數:20,代碼來源:alttoolbar_sidebar.py

示例5: __init__

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import timeout_add_seconds [as 別名]
def __init__(self):
        Gtk.Window.__init__(self)
        self.assistant = Gtk.Assistant()
        grid = Gtk.Grid(margin=4)
        grid.set_column_homogeneous(True)
        self.add(grid)

        self.grid = grid

        self.status_label, self.status_button = self.draw_status_elements()
        self.statistics_frame = self.draw_statistics_frame()
        self.top_queries_frame = self.draw_top_queries_frame()
        self.top_ads_frame = self.draw_top_ads_frame()
        self.updates_frame = self.draw_updates_frame()
        self.header_bar = self.draw_header_bar()
        self.hosts_combo = self.draw_hosts_combo()
        # Initial data fetch-and-display
        self.fetch_data_and_update_display(
            base_url, web_password)

        # Create a timer --> self.on_timer will be called periodically
        glib.timeout_add_seconds(update_interval_seconds, self.on_timer) 
開發者ID:daleosm,項目名稱:PiHole-Panel,代碼行數:24,代碼來源:main.py

示例6: run

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import timeout_add_seconds [as 別名]
def run(self):
        """
        Run the Sniffer main loop.
        """
        if self.adapter is not None:
            self._log.debug("Clearing the BlueZ device registry.")
            for path, _ in get_known_devices():
                self.adapter.RemoveDevice(path)

            self._log.debug("Registering the signals InterfacesAdded and PropertiesChanged.")
            bus = pydbus.SystemBus()
            bus.subscribe(
                sender=SERVICE_NAME,
                iface=OBJECT_MANAGER_INTERFACE,
                signal="InterfacesAdded",
                signal_fired=self._cb_interfaces_added
            )
            bus.subscribe(
                sender=SERVICE_NAME,
                iface=OBJECT_MANAGER_INTERFACE,
                signal="InterfacesRemoved",
                signal_fired=self._cb_interfaces_removed
            )
            bus.subscribe(
                sender=SERVICE_NAME,
                iface=PROPERTIES_INTERFACE,
                signal="PropertiesChanged",
                arg0=DEVICE_INTERFACE,
                signal_fired=self._cb_properties_changed
            )

            self._log.debug("Running the main loop.")
            if self.output_path is not None and self.backup_interval > 0:
                GLib.timeout_add_seconds(self.backup_interval, self._cb_backup_registry)
            if self.attempt_connection:
                GLib.timeout_add_seconds(self.queueing_interval, self._cb_connect_check)
            loop = GLib.MainLoop()
            loop.run()
        else:
            raise ValueError("Sniffer.run can only be called in a context "
                             "(e.g. `with Sniffer(...) as s: s.run()`)") 
開發者ID:scipag,項目名稱:btle-sniffer,代碼行數:43,代碼來源:sniffer.py

示例7: _on_close

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import timeout_add_seconds [as 別名]
def _on_close(self):
		if self._worker_thread is None:  # the socket was never successfully opened
			return
		getattr(self.logger, 'warning' if self.reconnect else 'info')('the server event socket has been closed')
		self._connect_event.clear()
		if self.__is_shutdown.is_set():
			return
		if self._worker_thread != threading.current_thread():
			return
		self._worker_thread = None
		if self.reconnect:
			self._reconnect_event_id = GLib.timeout_add_seconds(30, self._ws_reconnect) 
開發者ID:rsmusllp,項目名稱:king-phisher,代碼行數:14,代碼來源:server_events.py

示例8: __init__

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import timeout_add_seconds [as 別名]
def __init__(self, *args, **kwargs):
		super(CampaignViewDashboardTab, self).__init__(*args, **kwargs)
		self.graphs = []
		"""The :py:class:`.CampaignGraph` classes represented on the dash board."""

		dash_ports = {
			# dashboard position, (width, height)
			'top_left': (380, 200),
			'top_right': (380, 200),
			'bottom': (760, 200)
		}
		for dash_port, details in dash_ports.items():
			graph_name = self.config['dashboard.' + dash_port]
			cls = graphs.get_graph(graph_name)
			if not cls:
				self.logger.warning('could not get graph: ' + graph_name)
				logo_file_path = find.data_file('king-phisher-icon.svg')
				if logo_file_path:
					image = Gtk.Image.new_from_pixbuf(GdkPixbuf.Pixbuf.new_from_file_at_size(logo_file_path, 128, 128))
					image.show()
					self.gobjects['scrolledwindow_' + dash_port].add(image)
				continue
			graph_inst = cls(self.application, details, getattr(self, self.top_gobject).get_style_context())
			self.gobjects['scrolledwindow_' + dash_port].add(graph_inst.canvas)
			self.gobjects['box_' + dash_port].pack_end(graph_inst.navigation_toolbar, False, False, 0)
			self.graphs.append(graph_inst)
		self.logger.debug("dashboard refresh frequency set to {0} seconds".format(self.refresh_frequency))
		GLib.timeout_add_seconds(self.refresh_frequency, self.loader_idle_routine) 
開發者ID:rsmusllp,項目名稱:king-phisher,代碼行數:30,代碼來源:campaign.py

示例9: enable_timeout

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import timeout_add_seconds [as 別名]
def enable_timeout(self):
        """Reactivate timeout mechanism."""
        if self.timeout is None or self.timeout <= 0:
            return

        self.disable_timeout()
        self.timeout_id = GLib.timeout_add_seconds(
            self.timeout, self.timeout_callback
        ) 
開發者ID:mopidy,項目名稱:mopidy-mpd,代碼行數:11,代碼來源:network.py

示例10: __init__

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import timeout_add_seconds [as 別名]
def __init__(self, parent):
        Thread.__init__(self)
        self._parent = parent
        self.mgr = SensorManager()
        self.alive = Event()
        self.alive.set()
        GLib.timeout_add_seconds(self.mgr.get_interval(), self.run) 
開發者ID:fossfreedom,項目名稱:indicator-sysmonitor,代碼行數:9,代碼來源:sensors.py

示例11: play

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import timeout_add_seconds [as 別名]
def play(self, *args):
        """Play the current audio file."""
        def on_duration_changed():
            self.emit("duration-changed")
            return self.is_playing
        if self.is_playing:
            # Stop the current audio file from playing
            self.stop()
        self._playbin.set_state(Gst.State.PLAYING)
        self.is_playing = True
        self.emit("playing")
        GLib.timeout_add_seconds(1, on_duration_changed) 
開發者ID:bilelmoussaoui,項目名稱:Audio-Cutter,代碼行數:14,代碼來源:player.py

示例12: start

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import timeout_add_seconds [as 別名]
def start(discoverer):
    atexit.register(SubProcess.finishAllSubprocesses)
    pgnfile, gameno = queryGameno(sys.argv[1])
    analyzer = queryAnalyzer(discoverer.getAnalyzers())
    secs = queryTime()
    name1, name2 = pgnfile.get_player_names(gameno)
    print("%s will now analyze the game between %s and %s with %d seconds per move." % \
            (discoverer.getName(analyzer), name1, name2, secs))
    print()

    global game, values
    values = {}
    game = GameModel()
    game.setPlayers([DummyPlayer(), DummyPlayer()])
    analyzer = discoverer.initAnalyzerEngine(analyzer, ANALYZING, game.variant)
    analyzer.connect('analyze', onAnalyze)
    game.spectators[HINT] = analyzer
    game.loadAndStart(sys.argv[1], pgn, gameno, -1)

    def cb():
        if game.ply == game.lowply:
            on_finish()
            return False
        check_blund()
        return True
    GLib.timeout_add_seconds(secs, cb) 
開發者ID:pychess,項目名稱:pychess,代碼行數:28,代碼來源:blunders.py

示例13: __init__

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import timeout_add_seconds [as 別名]
def __init__(self, url, proxy=False, *args, **kwargs):
		super(WebView, self).__init__(*args, **kwargs)
		""" WebKit2 Webview widget """

		web_context = WebKit2.WebContext.get_default()
		web_context.set_tls_errors_policy(WebKit2.TLSErrorsPolicy.IGNORE)

		if proxy:
			# proxy False or "http://127.0.0.1:8080"
			web_context.set_network_proxy_settings(WebKit2.NetworkProxyMode.CUSTOM, WebKit2.NetworkProxySettings.new(proxy))
		
		self.set_hexpand(True)
		self.set_vexpand(True)

		self.toolbar = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)

		self.address_bar = Gtk.Entry()
		self.go_button = Gtk.Button("go")

		self.address_bar.set_text(url)

		self.toolbar.add(self.address_bar)
		self.toolbar.add(self.go_button)

		if proxy:
			GLib.timeout_add_seconds(2, self._reload)

		self.toolbar.set_hexpand(True)
		self.address_bar.set_hexpand(True)

		self.load_uri(url)
		self.toolbar.show_all()
		self.show_all()

		self.load_uri(url)

		self.connect("load-changed", self._load_changed)
		self.go_button.connect("clicked", self._load_uri) 
開發者ID:r3vn,項目名稱:badKarma,代碼行數:40,代碼來源:widgets.py

示例14: _row_click

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import timeout_add_seconds [as 別名]
def _row_click(self, widget, event):
        """
        event called when clicking on a row
        """
        print('_row_click')

        try:
            treepath, treecolumn, cellx, celly = \
                widget.get_path_at_pos(event.x, event.y)
        except:
            print("exit")
            return

        active_object = self.treestore_filter[treepath][1]
        print(active_object)

        if active_object:
            # we have a source
            self._user_clicked = True
            self.shell.props.display_page_tree.select(active_object)
            self.rbtree.expand_all()
            if self._last_click_source == active_object:
                self.text_renderer.props.editable = \
                    "PlaylistSource" in type(active_object).__name__
            else:
                self.text_renderer.props.editable = False
                self._last_click_source = active_object

        def delayed(*args):
            # save current state of each category in the treeview
            cat_vals = {}
            for category in self._category:
                path = self.treestore.get_path(self._category[category])
                if path:
                    cat_vals[category] = self.row_expanded(path)

            self.expanders = str(cat_vals)
            print(self.expanders)

        GLib.timeout_add_seconds(1, delayed) 
開發者ID:fossfreedom,項目名稱:alternative-toolbar,代碼行數:42,代碼來源:alttoolbar_sidebar.py

示例15: start_working_process

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import timeout_add_seconds [as 別名]
def start_working_process(self, interval, countdown):
        if self.pw > 0:
            GLib.source_remove(self.pw)
        print('interval', interval)
        print('pomodoros', self.pomodoros)
        self.pw = GLib.timeout_add_seconds(interval, countdown) 
開發者ID:atareao,項目名稱:pomodoro-indicator,代碼行數:8,代碼來源:pomodoro_indicator.py


注:本文中的gi.repository.GLib.timeout_add_seconds方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。