本文整理汇总了Python中gtk.ListStore.remove方法的典型用法代码示例。如果您正苦于以下问题:Python ListStore.remove方法的具体用法?Python ListStore.remove怎么用?Python ListStore.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gtk.ListStore
的用法示例。
在下文中一共展示了ListStore.remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PeersTab
# 需要导入模块: from gtk import ListStore [as 别名]
# 或者: from gtk.ListStore import remove [as 别名]
#.........这里部分代码省略.........
if icon != values[3]:
self.liststore.set_value(row, 7, icon)
if peer['progress'] != values[4]:
self.liststore.set_value(row, 8, peer['progress'])
else:
# Peer is not in list so we need to add it
# Create an int IP address for sorting purposes
if peer['ip'].count(':') == 1:
# This is an IPv4 address
ip_int = sum([int(byte) << shift
for byte, shift in zip(peer['ip'].split(':')[0].split('.'), (24, 16, 8, 0))])
peer_ip = peer['ip']
else:
# This is an IPv6 address
import socket
import binascii
# Split out the :port
ip = ':'.join(peer['ip'].split(':')[:-1])
ip_int = int(binascii.hexlify(socket.inet_pton(socket.AF_INET6, ip)), 16)
peer_ip = '[%s]:%s' % (ip, peer['ip'].split(':')[-1])
if peer['seed']:
icon = self.seed_pixbuf
else:
icon = self.peer_pixbuf
row = self.liststore.append([
self.get_flag_pixbuf(peer['country']),
peer_ip,
peer['client'],
peer['down_speed'],
peer['up_speed'],
peer['country'],
float(ip_int),
icon,
peer['progress']])
self.peers[peer['ip']] = row
# Now we need to remove any ips that were not in status["peers"] list
for ip in set(self.peers).difference(new_ips):
self.liststore.remove(self.peers[ip])
del self.peers[ip]
def clear(self):
self.liststore.clear()
def _on_button_press_event(self, widget, event):
"""This is a callback for showing the right-click context menu."""
log.debug('on_button_press_event')
# We only care about right-clicks
if self.torrent_id and event.button == 3:
self.peer_menu.popup(None, None, None, event.button, event.time)
return True
def _on_query_tooltip(self, widget, x, y, keyboard_tip, tooltip):
if not widget.get_tooltip_context(x, y, keyboard_tip):
return False
else:
model, path, _iter = widget.get_tooltip_context(x, y, keyboard_tip)
country_code = model.get(_iter, 5)[0]
if country_code != ' ' and country_code in COUNTRIES:
tooltip.set_text(COUNTRIES[country_code])
# widget here is self.listview
widget.set_tooltip_cell(tooltip, path, widget.get_column(0),
None)
return True
else:
return False
def on_menuitem_add_peer_activate(self, menuitem):
"""This is a callback for manually adding a peer"""
log.debug('on_menuitem_add_peer')
builder = Builder()
builder.add_from_file(deluge.common.resource_filename(
'deluge.ui.gtkui', os.path.join('glade', 'connect_peer_dialog.ui')
))
peer_dialog = builder.get_object('connect_peer_dialog')
txt_ip = builder.get_object('txt_ip')
response = peer_dialog.run()
if response:
value = txt_ip.get_text()
if value and ':' in value:
if ']' in value:
# ipv6
ip = value.split(']')[0][1:]
port = value.split(']')[1][1:]
else:
# ipv4
ip = value.split(':')[0]
port = value.split(':')[1]
if deluge.common.is_ip(ip):
log.debug('adding peer %s to %s', value, self.torrent_id)
client.core.connect_peer(self.torrent_id, ip, port)
peer_dialog.destroy()
return True