本文整理汇总了Python中popup.Popup.refresh方法的典型用法代码示例。如果您正苦于以下问题:Python Popup.refresh方法的具体用法?Python Popup.refresh怎么用?Python Popup.refresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类popup.Popup
的用法示例。
在下文中一共展示了Popup.refresh方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AllTorrents
# 需要导入模块: from popup import Popup [as 别名]
# 或者: from popup.Popup import refresh [as 别名]
class AllTorrents(BaseMode, component.Component):
def __init__(self, stdscr, encoding=None):
self.formatted_rows = None
self.torrent_names = None
self.cursel = 1
self.curoff = 1 # TODO: this should really be 0 indexed
self.column_string = ""
self.popup = None
self.messages = deque()
self.marked = []
self.last_mark = -1
self._sorted_ids = None
self._go_top = False
self._curr_filter = None
self.entering_search = False
self.search_string = None
self.cursor = 0
self.coreconfig = component.get("ConsoleUI").coreconfig
self.legacy_mode = None
self.__status_dict = {}
self.__torrent_info_id = None
BaseMode.__init__(self, stdscr, encoding)
component.Component.__init__(self, "AllTorrents", 1, depend=["SessionProxy"])
curses.curs_set(0)
self.stdscr.notimeout(0)
self.__split_help()
self.update_config()
component.start(["AllTorrents"])
self._info_fields = [
("Name",None,("name",)),
("State", None, ("state",)),
("Down Speed", format_utils.format_speed, ("download_payload_rate",)),
("Up Speed", format_utils.format_speed, ("upload_payload_rate",)),
("Progress", format_utils.format_progress, ("progress",)),
("ETA", deluge.common.ftime, ("eta",)),
("Path", None, ("save_path",)),
("Downloaded",deluge.common.fsize,("all_time_download",)),
("Uploaded", deluge.common.fsize,("total_uploaded",)),
("Share Ratio", format_utils.format_float, ("ratio",)),
("Seeders",format_utils.format_seeds_peers,("num_seeds","total_seeds")),
("Peers",format_utils.format_seeds_peers,("num_peers","total_peers")),
("Active Time",deluge.common.ftime,("active_time",)),
("Seeding Time",deluge.common.ftime,("seeding_time",)),
("Date Added",deluge.common.fdate,("time_added",)),
("Availability", format_utils.format_float, ("distributed_copies",)),
("Pieces", format_utils.format_pieces, ("num_pieces","piece_length")),
]
self.__status_keys = ["name","state","download_payload_rate","upload_payload_rate",
"progress","eta","all_time_download","total_uploaded", "ratio",
"num_seeds","total_seeds","num_peers","total_peers", "active_time",
"seeding_time","time_added","distributed_copies", "num_pieces",
"piece_length","save_path"]
# component start/update
def start(self):
component.get("SessionProxy").get_torrents_status(self.__status_dict, self.__status_fields).addCallback(self.set_state,False)
def update(self):
component.get("SessionProxy").get_torrents_status(self.__status_dict, self.__status_fields).addCallback(self.set_state,True)
if self.__torrent_info_id:
component.get("SessionProxy").get_torrent_status(self.__torrent_info_id, self.__status_keys).addCallback(self._on_torrent_status)
def update_config(self):
self.config = ConfigManager("console.conf",DEFAULT_PREFS)
self.__cols_to_show = [pref for pref in column_pref_names if self.config["show_%s"%pref]]
self.__columns = [prefs_to_names[col] for col in self.__cols_to_show]
self.__status_fields = column.get_required_fields(self.__columns)
for rf in ["state","name","queue"]: # we always need these, even if we're not displaying them
if not rf in self.__status_fields: self.__status_fields.append(rf)
self.__update_columns()
def __split_help(self):
self.__help_lines = format_utils.wrap_string(HELP_STR,(self.cols/2)-2)
def resume(self):
self._go_top = True
component.start(["AllTorrents"])
self.refresh()
def __update_columns(self):
self.column_widths = [self.config["%s_width"%c] for c in self.__cols_to_show]
req = sum(filter(lambda x:x >= 0,self.column_widths))
if (req > self.cols): # can't satisfy requests, just spread out evenly
cw = int(self.cols/len(self.__columns))
for i in range(0,len(self.column_widths)):
self.column_widths[i] = cw
else:
rem = self.cols - req
var_cols = len(filter(lambda x: x < 0,self.column_widths))
if (var_cols > 0):
vw = int(rem/var_cols)
#.........这里部分代码省略.........
示例2: TorrentDetail
# 需要导入模块: from popup import Popup [as 别名]
# 或者: from popup.Popup import refresh [as 别名]
class TorrentDetail(BaseMode, component.Component):
def __init__(self, alltorrentmode, torrentid, stdscr, encoding=None):
self.alltorrentmode = alltorrentmode
self.torrentid = torrentid
self.torrent_state = None
self.popup = None
self.messages = deque()
self._status_keys = ["files", "name","state","download_payload_rate","upload_payload_rate",
"progress","eta","all_time_download","total_uploaded", "ratio",
"num_seeds","total_seeds","num_peers","total_peers", "active_time",
"seeding_time","time_added","distributed_copies", "num_pieces",
"piece_length","save_path","file_progress","file_priorities","message"]
self._info_fields = [
("Name",None,("name",)),
("State", None, ("state",)),
("Status",None,("message",)),
("Down Speed", format_utils.format_speed, ("download_payload_rate",)),
("Up Speed", format_utils.format_speed, ("upload_payload_rate",)),
("Progress", format_utils.format_progress, ("progress",)),
("ETA", deluge.common.ftime, ("eta",)),
("Path", None, ("save_path",)),
("Downloaded",deluge.common.fsize,("all_time_download",)),
("Uploaded", deluge.common.fsize,("total_uploaded",)),
("Share Ratio", lambda x:x < 0 and "∞" or "%.3f"%x, ("ratio",)),
("Seeders",format_utils.format_seeds_peers,("num_seeds","total_seeds")),
("Peers",format_utils.format_seeds_peers,("num_peers","total_peers")),
("Active Time",deluge.common.ftime,("active_time",)),
("Seeding Time",deluge.common.ftime,("seeding_time",)),
("Date Added",deluge.common.fdate,("time_added",)),
("Availability", lambda x:x < 0 and "∞" or "%.3f"%x, ("distributed_copies",)),
("Pieces", format_utils.format_pieces, ("num_pieces","piece_length")),
]
self.file_list = None
self.current_file = None
self.current_file_idx = 0
self.file_limit = maxint
self.file_off = 0
self.more_to_draw = False
self.column_string = ""
self.files_sep = None
self.marked = {}
BaseMode.__init__(self, stdscr, encoding)
component.Component.__init__(self, "TorrentDetail", 1, depend=["SessionProxy"])
self.__split_help()
self.column_names = ["Filename", "Size", "Progress", "Priority"]
self.__update_columns()
component.start(["TorrentDetail"])
curses.curs_set(0)
self.stdscr.notimeout(0)
# component start/update
def start(self):
component.get("SessionProxy").get_torrent_status(self.torrentid, self._status_keys).addCallback(self.set_state)
def update(self):
component.get("SessionProxy").get_torrent_status(self.torrentid, self._status_keys).addCallback(self.set_state)
def set_state(self, state):
log.debug("got state")
need_prio_update = False
if not self.file_list:
# don't keep getting the files once we've got them once
if state.get("files"):
self.files_sep = "{!green,black,bold,underline!}%s"%(("Files (torrent has %d files)"%len(state["files"])).center(self.cols))
self.file_list,self.file_dict = self.build_file_list(state["files"],state["file_progress"],state["file_priorities"])
self._status_keys.remove("files")
else:
self.files_sep = "{!green,black,bold,underline!}%s"%(("Files (File list unknown)").center(self.cols))
need_prio_update = True
self.__fill_progress(self.file_list,state["file_progress"])
for i,prio in enumerate(state["file_priorities"]):
if self.file_dict[i][6] != prio:
need_prio_update = True
self.file_dict[i][6] = prio
if need_prio_update:
self.__fill_prio(self.file_list)
del state["file_progress"]
del state["file_priorities"]
self.torrent_state = state
self.refresh()
def __split_help(self):
self.__help_lines = format_utils.wrap_string(HELP_STR,(self.cols/2)-2)
# split file list into directory tree. this function assumes all files in a
# particular directory are returned together. it won't work otherwise.
# returned list is a list of lists of the form:
# [file/dir_name,index,size,children,expanded,progress,priority]
# for directories index values count down from maxint (for marking usage),
# for files the index is the value returned in the
# state object for use with other libtorrent calls (i.e. setting prio)
#
# Also returns a dictionary that maps index values to the file leaves
# for fast updating of progress and priorities
def build_file_list(self, file_tuples,prog,prio):
#.........这里部分代码省略.........