本文整理汇总了Python中gtk.Button.set_sensitive方法的典型用法代码示例。如果您正苦于以下问题:Python Button.set_sensitive方法的具体用法?Python Button.set_sensitive怎么用?Python Button.set_sensitive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gtk.Button
的用法示例。
在下文中一共展示了Button.set_sensitive方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __on_plugin_directories_button_click
# 需要导入模块: from gtk import Button [as 别名]
# 或者: from gtk.Button import set_sensitive [as 别名]
def __on_plugin_directories_button_click(self, button):
"""Present a dialog to the user for selecting extra plugin directories
and process the request."""
dia = Dialog('Plugin Directories',
None, DIALOG_MODAL,
(STOCK_OK, RESPONSE_OK,
STOCK_CANCEL, RESPONSE_CANCEL ) )
dia.resize(500, 300)
dia.vbox.set_spacing(8)
# Setup the tree view of plugin directories.
model = ListStore(str) # each row contains a single string
tv = TreeView(model)
cell = CellRendererText()
column = TreeViewColumn('Directory', cell, text = 0)
tv.append_column(column)
dia.vbox.pack_start(tv)
# Populate the tree view.
plugin_directories = \
get_plugins_directories_from_config(self.config, self.config_path)
for plugin_directory in plugin_directories:
row = (plugin_directory,)
model.append(row)
modify_box = HBox(spacing = 8)
# Setup the remove directory button.
remove_button = Button('Remove')
remove_button.set_sensitive(False) # no directory selected initially
remove_button.connect('clicked', self.__on_remove, tv)
modify_box.pack_end(remove_button, expand = False)
tv.connect('cursor-changed', self.__on_select, remove_button)
# Setup the add directory button.
add_button = Button('Add')
add_button.connect('clicked', self.__on_add, tv)
modify_box.pack_end(add_button, expand = False)
dia.vbox.pack_start(modify_box, expand = False)
# Setup the "already included directories" label.
included_label = Label('Plugins in the PYTHONPATH are already ' +
'available to BoKeep.')
# Use a horizontal box to left-justify the label. For some reason,
# the label's set_justification property doesn't work for me.
label_box = HBox()
label_box.pack_start(included_label, expand = False)
dia.vbox.pack_start(label_box, expand = False)
dia.show_all()
dia_result = dia.run()
if dia_result == RESPONSE_OK:
# Remove the old plugin directories from the program's path.
plugin_directories = \
get_plugins_directories_from_config(self.config,
self.config_path)
for plugin_directory in plugin_directories:
path.remove(plugin_directory)
# Get the new plugin directories from the dialog.
plugin_directories = []
for row in model:
plugin_directory = row[0]
plugin_directories.append(plugin_directory)
# Update the BoKeep PYTHONPATH so that new plugins can be loaded and
# populate the list of possible new plugins.
for plugin_directory in plugin_directories:
path.append(plugin_directory)
self.__populate_possible_plugins()
# Save the new plugin directories in the configuration file.
set_plugin_directories_in_config(self.config,
self.config_path, plugin_directories)
dia.destroy()