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


Python Popup.add_line方法代码示例

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


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

示例1: AllTorrents

# 需要导入模块: from popup import Popup [as 别名]
# 或者: from popup.Popup import add_line [as 别名]

#.........这里部分代码省略.........
    def current_torrent_id(self):
        if self._sorted_ids:
            return self._sorted_ids[self.cursel-1]
        else:
            return None

    def _selected_torrent_ids(self):
        ret = []
        for i in self.marked:
            ret.append(self._sorted_ids[i-1])
        return ret

    def _on_torrent_status(self, state):
        if (self.popup):
            self.popup.clear()
            name = state["name"]
            off = int((self.cols/4)-(len(name)/2))
            self.popup.set_title(name)
            for i,f in enumerate(self._info_fields):
                if f[1] != None:
                    args = []
                    try:
                        for key in f[2]:
                            args.append(state[key])
                    except:
                        log.debug("Could not get info field: %s",e)
                        continue
                    info = f[1](*args)
                else:
                    info = state[f[2][0]]
                
                nl = len(f[0])+4
                if (nl+len(info))>self.popup.width:
                    self.popup.add_line("{!info!}%s: {!input!}%s"%(f[0],info[:(self.popup.width - nl)]))
                    info = info[(self.popup.width - nl):]
                    n = self.popup.width-3
                    chunks = [info[i:i+n] for i in xrange(0, len(info), n)]
                    for c in chunks:
                        self.popup.add_line(" %s"%c)
                else:
                    self.popup.add_line("{!info!}%s: {!input!}%s"%(f[0],info))
            self.refresh()
        else:
            self.__torrent_info_id = None
            

    def on_resize(self, *args):
        BaseMode.on_resize_norefresh(self, *args)
        self.__update_columns()
        self.__split_help()
        if self.popup:
            self.popup.handle_resize()
        self.refresh()

    def _queue_sort(self, v1, v2):
        if v1 == v2:
            return 0
        if v2 < 0:
            return -1
        if v1 < 0:
            return 1
        if v1 > v2:
            return 1
        if v2 > v1:
            return -1
开发者ID:NoGare,项目名称:deluge1,代码行数:69,代码来源:alltorrents.py

示例2: TorrentDetail

# 需要导入模块: from popup import Popup [as 别名]
# 或者: from popup.Popup import add_line [as 别名]

#.........这里部分代码省略.........
        for f in files:
            if f[3]: # dir, check if i'm setting on whole dir, then recurse
                if f[1] in self.marked: # marked, recurse and update all children with new prio
                    parent_prio = selected_prio
                    self.build_prio_list(f[3],ret_list,parent_prio,selected_prio)
                    parent_prio = -1
                else: # not marked, just recurse
                    self.build_prio_list(f[3],ret_list,parent_prio,selected_prio)
            else: # file, need to add to list
                if f[1] in self.marked or parent_prio >= 0:
                    # selected (or parent selected), use requested priority
                    ret_list.append((f[1],selected_prio))
                else:
                    # not selected, just keep old priority
                    ret_list.append((f[1],f[6]))

    def do_priority(self, idx, data):
        plist = []
        self.build_prio_list(self.file_list,plist,-1,data)
        plist.sort()
        priorities = [p[1] for p in plist]
        log.debug("priorities: %s", priorities)

        client.core.set_torrent_file_priorities(self.torrentid, priorities)

        if len(self.marked) == 1:
            self.marked = {}
        return True

    # show popup for priority selections
    def show_priority_popup(self):
        if self.marked:
            self.popup = SelectablePopup(self,"Set File Priority",self.do_priority)
            self.popup.add_line("_Do Not Download",data=deluge.common.FILE_PRIORITY["Do Not Download"])
            self.popup.add_line("_Normal Priority",data=deluge.common.FILE_PRIORITY["Normal Priority"])
            self.popup.add_line("_High Priority",data=deluge.common.FILE_PRIORITY["High Priority"])
            self.popup.add_line("H_ighest Priority",data=deluge.common.FILE_PRIORITY["Highest Priority"])

    def __mark_unmark(self,idx):
        if idx in self.marked:
            del self.marked[idx]
        else:
            self.marked[idx] = True

    def _doRead(self):
        c = self.stdscr.getch()

        if self.popup:
            if self.popup.handle_read(c):
                self.popup = None
            self.refresh()
            return

        if c > 31 and c < 256:
            if chr(c) == 'Q':
                from twisted.internet import reactor
                if client.connected():
                    def on_disconnect(result):
                        reactor.stop()
                    client.disconnect().addCallback(on_disconnect)
                else:
                    reactor.stop()            
                return
            elif chr(c) == 'q':
                self.back_to_overview()
                return
开发者ID:NoGare,项目名称:deluge1,代码行数:70,代码来源:torrentdetail.py


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