本文整理汇总了Python中gtk.ListStore.clear方法的典型用法代码示例。如果您正苦于以下问题:Python ListStore.clear方法的具体用法?Python ListStore.clear怎么用?Python ListStore.clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gtk.ListStore
的用法示例。
在下文中一共展示了ListStore.clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MemberFeeCollectionEditor
# 需要导入模块: from gtk import ListStore [as 别名]
# 或者: from gtk.ListStore import clear [as 别名]
class MemberFeeCollectionEditor(object):
def __init__(self, trans, transid, plugin, gui_parent,
change_register_function):
self.fee_trans = trans
self.transid = transid
self.memberfee_plugin = plugin
self.change_register_function = change_register_function
load_glade_file_get_widgets_and_connect_signals(
get_memberfee_glade_file(),
'window1', self, self)
self.vbox1.reparent(gui_parent)
self.window1.hide()
self.fee_spread_liststore = ListStore(str, str)
self.fee_spread_list.set_model(self.fee_spread_liststore)
column_one = TreeViewColumn('Date')
column_two = TreeViewColumn('Amount')
self.fee_spread_list.append_column(column_one)
self.fee_spread_list.append_column(column_two)
for i, column in enumerate((column_one, column_two)):
cell = CellRendererText()
column.pack_start(cell, False)
column.add_attribute(cell, 'text', i)
self.populate_fee_spread_liststore()
def populate_fee_spread_liststore(self):
self.fee_spread_liststore.clear()
for month in gen_n_months_starting_from(first_of(date.today()), 4):
self.fee_spread_liststore.append((month, '10'))
def detach(self):
self.vbox1.reparent(self.window1)
def day_changed(self, *args):
print('day_changed')
def amount_collected_changed(self, *args):
print('amount_collected_changed')
def member_changed(self, *args):
print('member_changed')
示例2: InputWidget
# 需要导入模块: from gtk import ListStore [as 别名]
# 或者: from gtk.ListStore import clear [as 别名]
#.........这里部分代码省略.........
return True
def change_category_cb(self, widget):
"""Change current category."""
if widget.name == "prev_category_w":
direction = -1
direction = 1
category_index = self.categories_list.index( \
self.widgets["CurrentCategory"].get_text())
try:
new_category = self.categories_list[category_index + direction]
except IndexError:
if direction:
new_category = self.categories_list[0]
else:
new_category = self.categories_list[len(self.categories_list)-1]
self.widgets["CurrentCategory"].set_text(new_category)
def create_new_category_cb(self, widget):
"""Create new category."""
new_category = self.widgets["NewCategory"].get_text()
if new_category:
self.categories_list.append(new_category)
self.widgets["NewCategory"].set_text("")
self.widgets["CurrentCategory"].set_text(new_category)
self.hide_add_category_block_cb(None)
def add_picture_cb(self, widget):
"""Show image selection dialog."""
self.main_widget().soundplayer.stop()
self.liststore.clear()
self.imagedir = self.conf['imagedir']
if not os.path.exists(self.imagedir):
self.imagedir = "./images" # on Desktop
if not os.path.exists(self.imagedir):
self.main_widget().information_box(\
_("'Images' directory does not exist!"))
return
if os.listdir(self.imagedir):
self.widgets["MediaDialog"].show()
for fname in os.listdir(self.imagedir):
if os.path.isfile(os.path.join(self.imagedir, fname)):
pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(\
os.path.join(self.imagedir, fname), 100, 100)
self.liststore.append(["", "img", fname, \
self.imagedir, pixbuf])
else:
self.main_widget().information_box(\
_("There are no files in 'Images' directory!"))
def select_item_cb(self, widget):
"""
Set html-text with media path and type when user
select media filefrom media selection dialog.
"""
self.widgets["MediaDialog"].hide()
item_index = self.w_tree.get_widget("iconview_widget"). \
get_selected_items()[0]
item_type = self.liststore.get_value( \
self.liststore.get_iter(item_index), 1)
item_fname = self.liststore.get_value( \
self.liststore.get_iter(item_index), 2)
item_dirname = self.liststore.get_value( \
示例3: MainWindow
# 需要导入模块: from gtk import ListStore [as 别名]
# 或者: from gtk.ListStore import clear [as 别名]
class MainWindow(object):
"""Represents the main window for the default BoKeep shell.
This class has a lot of imperitive/procedural code with plenty of side
effects, and the cost of them has started to show in subtle bugs.
It would be a lost worse if the state machine BoKeepGuiState wasn't used.
Could be a lot better if an even higher level state machine or something
a lot more functional and a lot less imperitive were used.
Oh well, in the meantime, here's a depth call graph with a little pseudo-
code of the most intertangled functions from this module and major calls to
other modules that alter the state of the interface.
This is done starting from most significant entry points into this
class's code.
Please keep it up to date and also try to reflect the interdependencies
in the in per function docstrings.
This is pretty much the only way one can get a big picture overview of
how much of the code here is interrelated
__init__ (called by shell_startup prior to gtk.main() )
build_gui
set_sensitivities_and_status
set_backend_error_indicator
set_transid_label
startup_event_handler (first thing called by gtk.main() )
after_background_load
if no book selected and at least one available
guistate.do_action(BOOK_CHANGE, first book)
else if a book selected matches one that exists
guistate.do_action(RESET)
else if no book selected that matches, or none even available
guistate.do_action(BOOK_CHANGE, None)
books_combobox_model.append
books_combobox.set_active
if a current book in the combo can not be determined
set_book_from_combo
guistate.do_action(BOOK_CHANGE, current_book_selected)
refresh_trans_types_and_set_sensitivities_and_status
refresh_trans_types
trans_type_model.clear
trans_type_model.append
if a transaction type was found matching current
set_transcombo_index
reset_trans_view
self.hide_transaction
self.current_editor set with new editor instance
else no transaction type found
hide_transaction
END refresh_trans_types as called by..
refresh_trans_types_and_set_sensitivities_and_status
set_sensitivities_and_status
set_backend_error_indicator
set_transid_label
END refresh_trans_types_and_set_sensitivities_and_status
as called by after_background_load
END after_background_load as called by startup_event_handler
END startup_event_handler
on_books_combobox_changed (called by gtk gui thread when book combo changed)
set_book_from_combo
guistate.do_action(BOOK_CHANGE, newly selected book)
refresh_trans_types_and_set_sensitivities_and_status
refresh_trans_types
trans_type_model.clear
trans_type_model.append
if a transaction type was found matching current
set_transcombo_index
reset_trans_view
self.hide_transaction
self.current_editor set with new editor instance
else no transaction type found
hide_transaction
END refresh_trans_types as called by..
refresh_trans_types_and_set_sensitivities_and_status
set_sensitivities_and_status
set_backend_error_indicator
set_transid_label
END refresh_trans_types_and_set_sensitivities_and_status as
called by on_books_combobox_changed
END on_books_combobox_changed
new_button_clicked (called by gtk gui thread when new button clicked)
guistate.do_action(NEW)
set_trans_type_combo_to_current_and_reset_view
set_transcombo_index
reset_trans_view
self.hide_transaction
self.current_editor set with new editor instance
set_sensitivities_and_status
set_backend_error_indicator
set_transid_label
delete_button_clicked (called by gtk gui thread when delete button
clicked)
guistate.do_action(DELETE)
if there is no transaction left
#.........这里部分代码省略.........
示例4: PeersTab
# 需要导入模块: from gtk import ListStore [as 别名]
# 或者: from gtk.ListStore import clear [as 别名]
#.........这里部分代码省略.........
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]
column.set_sizing(TREE_VIEW_COLUMN_FIXED)
column.set_fixed_width(cstate['width'] if cstate['width'] > 0 else 10)
if state['sort_id'] == index and state['sort_order'] is not None:
column.set_sort_indicator(True)
column.set_sort_order(state['sort_order'])
if cstate['position'] != index:
# Column is in wrong position
if cstate['position'] == 0:
self.listview.move_column_after(column, None)
elif self.listview.get_columns()[cstate['position'] - 1].get_title() != cname:
self.listview.move_column_after(column, self.listview.get_columns()[cstate['position'] - 1])
def update(self):
# Get the first selected torrent
torrent_id = component.get('TorrentView').get_selected_torrents()
# Only use the first torrent in the list or return if None selected
if len(torrent_id) != 0:
torrent_id = torrent_id[0]
else:
# No torrent is selected in the torrentview
self.liststore.clear()
return
if torrent_id != self.torrent_id:
# We only want to do this if the torrent_id has changed
self.liststore.clear()
self.peers = {}
self.torrent_id = torrent_id
component.get('SessionProxy').get_torrent_status(torrent_id, ['peers']).addCallback(self._on_get_torrent_status)
def get_flag_pixbuf(self, country):
if not country.strip():
return None
if country not in self.cached_flag_pixbufs:
# We haven't created a pixbuf for this country yet
try:
self.cached_flag_pixbufs[country] = pixbuf_new_from_file(
deluge.common.resource_filename(
'deluge',
os.path.join('ui', 'data', 'pixmaps', 'flags', country.lower() + '.png')))
except Exception as ex:
log.debug('Unable to load flag: %s', ex)
return None
return self.cached_flag_pixbufs[country]
def _on_get_torrent_status(self, status):
new_ips = set()
for peer in status['peers']:
new_ips.add(peer['ip'])
if peer['ip'] in self.peers: