本文整理汇总了Python中gtk.ListStore.get_sort_column_id方法的典型用法代码示例。如果您正苦于以下问题:Python ListStore.get_sort_column_id方法的具体用法?Python ListStore.get_sort_column_id怎么用?Python ListStore.get_sort_column_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gtk.ListStore
的用法示例。
在下文中一共展示了ListStore.get_sort_column_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PeersTab
# 需要导入模块: from gtk import ListStore [as 别名]
# 或者: from gtk.ListStore import get_sort_column_id [as 别名]
#.........这里部分代码省略.........
column.pack_start(render, False)
column.set_cell_data_func(render, cell_data_speed_down, 3)
column.set_sort_column_id(3)
column.set_clickable(True)
column.set_resizable(True)
column.set_expand(False)
column.set_min_width(50)
column.set_reorderable(True)
self.listview.append_column(column)
# Up Speed column
column = TreeViewColumn(_('Up Speed'))
render = CellRendererText()
column.pack_start(render, False)
column.set_cell_data_func(render, cell_data_speed_up, 4)
column.set_sort_column_id(4)
column.set_clickable(True)
column.set_resizable(True)
column.set_expand(False)
column.set_min_width(50)
# Bugfix: Last column needs max_width set to stop scrollbar appearing
column.set_max_width(150)
column.set_reorderable(True)
self.listview.append_column(column)
self.listview.set_model(self.liststore)
self.load_state()
self.torrent_id = None
def save_state(self):
# Get the current sort order of the view
column_id, sort_order = self.liststore.get_sort_column_id()
# Setup state dict
state = {
'columns': {},
'sort_id': column_id,
'sort_order': int(sort_order) if sort_order else None
}
for index, column in enumerate(self.listview.get_columns()):
state['columns'][column.get_title()] = {
'position': index,
'width': column.get_width()
}
save_pickled_state_file('peers_tab.state', state)
def load_state(self):
state = load_pickled_state_file('peers_tab.state')
if state is None:
return
if len(state['columns']) != len(self.listview.get_columns()):
log.warning('peers_tab.state is not compatible! rejecting..')
return
if state['sort_id'] and state['sort_order'] is not None:
self.liststore.set_sort_column_id(state['sort_id'], state['sort_order'])
for (index, column) in enumerate(self.listview.get_columns()):
cname = column.get_title()
if cname in state['columns']:
cstate = state['columns'][cname]