本文整理汇总了Python中gi.repository.GLib.PRIORITY_LOW属性的典型用法代码示例。如果您正苦于以下问题:Python GLib.PRIORITY_LOW属性的具体用法?Python GLib.PRIORITY_LOW怎么用?Python GLib.PRIORITY_LOW使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类gi.repository.GLib
的用法示例。
在下文中一共展示了GLib.PRIORITY_LOW属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print_message
# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import PRIORITY_LOW [as 别名]
def print_message(self, message, log_level):
with self._lock:
if log_level <= log.logging.VERBOSE and self._enables.get('VERBOSE', False):
GLib.idle_add(self.print_to_text_view, message, self.filtered_buffer, "debug",
priority=GLib.PRIORITY_LOW)
if log.logging.VERBOSE < log_level <= log.logging.DEBUG and self._enables.get('DEBUG', True):
GLib.idle_add(self.print_to_text_view, message, self.filtered_buffer, "debug",
priority=self.logging_priority)
elif log.logging.DEBUG < log_level <= log.logging.INFO and self._enables.get('INFO', True):
GLib.idle_add(self.print_to_text_view, message, self.filtered_buffer, "info",
priority=self.logging_priority)
elif log.logging.INFO < log_level <= log.logging.WARNING and self._enables.get('WARNING', True):
GLib.idle_add(self.print_to_text_view, message, self.filtered_buffer, "warning",
priority=self.logging_priority)
elif log.logging.WARNING < log_level and self._enables.get('ERROR', True):
GLib.idle_add(self.print_to_text_view, message, self.filtered_buffer, "error",
priority=self.logging_priority)
示例2: onPlayerRemoved
# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import PRIORITY_LOW [as 别名]
def onPlayerRemoved(self, players, player):
def do_onPlayerRemoved(players, player):
log.debug("%s" % player,
extra={"task": (self.connection.username,
"PTS.onPlayerRemoved")})
if player not in self.players:
return
if self.store.iter_is_valid(self.players[player]["ti"]):
self.store.remove(self.players[player]["ti"])
for key in ("status", "game", "titles"):
if player.handler_is_connected(self.players[player][key]):
player.disconnect(self.players[player][key])
if player.game and "private" in self.players[player] and \
player.game.handler_is_connected(self.players[player]["private"]):
player.game.disconnect(self.players[player]["private"])
if player.handler_is_connected(self.players[player]["ratings"]):
player.disconnect(self.players[player]["ratings"])
del self.players[player]
count = len(self.players)
self.widgets["playersOnlineLabel"].set_text(_("Players: %d") % count)
GLib.idle_add(do_onPlayerRemoved, players, player, priority=GLib.PRIORITY_LOW)
示例3: run_generator
# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import PRIORITY_LOW [as 别名]
def run_generator(function):
gen = function()
GLib.idle_add(lambda: next(gen, False), priority=GLib.PRIORITY_LOW)
示例4: __init__
# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import PRIORITY_LOW [as 别名]
def __init__(self):
View.__init__(self)
self._lock = threading.Lock()
self.text_view = Gtk.TextView()
self.text_view.set_property('editable', False)
self.filtered_buffer = self.create_text_buffer()
self.text_view.set_buffer(self.filtered_buffer)
self.text_view.set_border_window_size(Gtk.TextWindowType.LEFT, 10)
self.text_view.set_border_window_size(Gtk.TextWindowType.RIGHT, 10)
self.text_view.set_border_window_size(Gtk.TextWindowType.TOP, 10)
self.text_view.set_border_window_size(Gtk.TextWindowType.BOTTOM, 10)
self._enables = {}
self._auto_scroll_handler_id = None
scrollable = Gtk.ScrolledWindow()
scrollable.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
scrollable.set_name('console_scroller')
scrollable.add(self.text_view)
self.text_view.show()
self['scrollable'] = scrollable
self.top = 'scrollable'
self.quit_flag = False
self.logging_priority = global_gui_config.get_config_value("LOGGING_CONSOLE_GTK_PRIORITY", GLib.PRIORITY_LOW)
self._stored_line_number = None
self._stored_line_offset = None
self._stored_text_of_line = None
self._stored_relative_lines = None
示例5: onGameAdd
# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import PRIORITY_LOW [as 别名]
def onGameAdd(self, games, new_games):
game_store = {}
for game in new_games:
game_store[game] = (game, self.clearpix,
game.wplayer.name + game.wplayer.display_titles(),
game.wplayer.getRatingForCurrentGame(),
game.bplayer.name + game.bplayer.display_titles(),
game.bplayer.getRatingForCurrentGame(),
game.display_text, game.display_rated)
def do_onGameAdd(games, new_games, game_store):
for game in new_games:
# game removed before we finish processing "games /bslwBzSLx"
if game not in game_store:
continue
# log.debug("%s" % game,
# extra={"task": (self.connection.username, "GTS.onGameAdd")})
ti = self.store.append(game_store[game])
self.games[game] = {"ti": ti}
self.games[game]["private_cid"] = game.connect(
"notify::private", self.private_changed)
self._update_gamesrunning_label()
GLib.idle_add(do_onGameAdd,
games,
new_games,
game_store,
priority=GLib.PRIORITY_LOW)
示例6: onGameRemove
# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import PRIORITY_LOW [as 别名]
def onGameRemove(self, games, game):
def do_onGameRemove(games, game):
log.debug(
"%s" % game,
extra={"task": (self.connection.username, "GTS.onGameRemove")})
if game not in self.games:
return
if self.store.iter_is_valid(self.games[game]["ti"]):
self.store.remove(self.games[game]["ti"])
if game.handler_is_connected(self.games[game]["private_cid"]):
game.disconnect(self.games[game]["private_cid"])
del self.games[game]
self._update_gamesrunning_label()
GLib.idle_add(do_onGameRemove, games, game, priority=GLib.PRIORITY_LOW)
示例7: online_changed
# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import PRIORITY_LOW [as 别名]
def online_changed(self, player, prop):
if player.online:
GLib.idle_add(self.emit,
"FICSPlayerEntered",
[player, ],
priority=GLib.PRIORITY_LOW)
# This method is a temporary hack until ChatWindow/ChatManager are
# converted to use FICSPlayer references rather than player's names
示例8: __init__
# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import PRIORITY_LOW [as 别名]
def __init__(self, callback):
super().__init__()
# Worker process to handle counting.
self.counting = False
self.count_pending_text = None
self.parent_conn, child_conn = Pipe()
Process(target=self.do_count, args=(child_conn,), daemon=True).start()
GLib.io_add_watch(
self.parent_conn.fileno(), GLib.PRIORITY_LOW, GLib.IO_IN, self.on_counted, callback)
示例9: call_gui_callback
# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import PRIORITY_LOW [as 别名]
def call_gui_callback(callback, *args, **kwargs):
"""Wrapper method for GLib.idle_add
This method is intended as replacement for idle_add. It wraps the method with a callback option. The advantage is
that this way, the call is blocking. The method return, when the callback method has been called and executed.
:param callback: The callback method, e.g. on_open_activate
:param args: The parameters to be passed to the callback method
"""
from future.utils import raise_
from threading import Condition
import sys
from rafcon.utils import log
global exception_info, result
from gi.repository import GLib
condition = Condition()
exception_info = None
@log.log_exceptions()
def fun():
"""Call callback and notify condition variable
"""
global exception_info, result
result = None
try:
result = callback(*args, **kwargs)
except:
# Exception within this asynchronously called function won't reach pytest. This is why we have to store
# the information about the exception to re-raise it at the end of the synchronous call.
exception_info = sys.exc_info()
finally: # Finally is also executed in the case of exceptions
condition.acquire()
condition.notify()
condition.release()
if "priority" in kwargs:
priority = kwargs.pop("priority")
else:
priority = GLib.PRIORITY_LOW
with condition:
GLib.idle_add(fun, priority=priority)
# Wait for the condition to be notified
# TODO: implement timeout that raises an exception
condition.wait()
if exception_info:
e_class, e_instance, e_traceback = exception_info
raise_(e_instance, None, e_traceback)
return result
示例10: onPlayerAdded
# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import PRIORITY_LOW [as 别名]
def onPlayerAdded(self, players, new_players):
# Let the hard work to be done in the helper connection thread
np = {}
for player in new_players:
np[player] = (player, player.getIcon(),
player.name + player.display_titles(), player.blitz,
player.standard, player.lightning,
player.display_status,
get_player_tooltip_text(player))
def do_onPlayerAdded(players, new_players, np):
for player in new_players:
# log.debug("%s" % player,
# extra={"task": (self.connection.username,
# "PTS.onPlayerAdded")})
if player in self.players:
# log.warning("%s already in self" % player,
# extra={"task": (self.connection.username,
# "PTS.onPlayerAdded")})
continue
# player can leave before we finish processing "who IbslwBzSLx"
if player not in np:
continue
self.players[player] = {}
self.players[player]["ti"] = self.store.append(np[player])
self.players[player]["status"] = player.connect(
"notify::status", self.status_changed)
self.players[player]["game"] = player.connect(
"notify::game", self.status_changed)
self.players[player]["titles"] = player.connect(
"notify::titles", self.titles_changed)
if player.game:
self.players[player]["private"] = player.game.connect(
"notify::private", self.private_changed, player)
self.players[player]["ratings"] = player.connect(
"ratings_changed", self.elo_changed, player)
count = len(self.players)
self.widgets["playersOnlineLabel"].set_text(_("Players: %d") %
count)
return False
GLib.idle_add(do_onPlayerAdded,
players,
new_players,
np,
priority=GLib.PRIORITY_LOW)