本文整理汇总了Python中popup.Popup.handle_read方法的典型用法代码示例。如果您正苦于以下问题:Python Popup.handle_read方法的具体用法?Python Popup.handle_read怎么用?Python Popup.handle_read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类popup.Popup
的用法示例。
在下文中一共展示了Popup.handle_read方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AllTorrents
# 需要导入模块: from popup import Popup [as 别名]
# 或者: from popup.Popup import handle_read [as 别名]
#.........这里部分代码省略.........
self.search_string = None
self.entering_search = False
elif c == 10 or c == curses.KEY_ENTER:
self.entering_search = False
if self.search_string:
self.__do_search()
else:
self.search_string = None
elif c > 31 and c < 256:
stroke = chr(c)
uchar = ""
while not uchar:
try:
uchar = stroke.decode(self.encoding)
except UnicodeDecodeError:
c = self.stdscr.getch()
stroke += chr(c)
if uchar:
if self.cursor == len(self.search_string):
self.search_string += uchar
else:
# Insert into string
self.search_string = self.search_string[:self.cursor] + uchar + self.search_string[self.cursor:]
# Move the cursor forward
self.cursor+=1
def _doRead(self):
# Read the character
effected_lines = None
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
if self.formatted_rows==None or self.popup:
return
elif self.entering_search:
self.__update_search(c)
self.refresh([])
return
#log.error("pressed key: %d\n",c)
#if c == 27: # handle escape
# log.error("CANCEL")
# Navigate the torrent list
if c == curses.KEY_UP:
if self.cursel == 1: return
if not self._scroll_up(1):
effected_lines = [self.cursel-1,self.cursel]
示例2: TorrentDetail
# 需要导入模块: from popup import Popup [as 别名]
# 或者: from popup.Popup import handle_read [as 别名]
#.........这里部分代码省略.........
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
if c == 27 or c == curses.KEY_LEFT:
self.back_to_overview()
return
if not self.torrent_state:
# actions below only makes sense if there is a torrent state
return
# Navigate the torrent list
if c == curses.KEY_UP:
self.file_list_up()
elif c == curses.KEY_PPAGE:
pass
elif c == curses.KEY_DOWN:
self.file_list_down()
elif c == curses.KEY_NPAGE:
pass
# Enter Key
elif c == curses.KEY_ENTER or c == 10:
self.marked[self.current_file[1]] = True
self.show_priority_popup()
# space
elif c == 32:
self.expcol_cur_file()
else:
if c > 31 and c < 256:
if chr(c) == 'm':
if self.current_file:
self.__mark_unmark(self.current_file[1])
elif chr(c) == 'c':
self.marked = {}
elif chr(c) == 'a':
torrent_actions_popup(self,[self.torrentid],details=False)
return
elif chr(c) == 'h':
self.popup = Popup(self,"Help",init_lines=self.__help_lines)
self.refresh()