def run(self): response = Dialog.run(self) self.destroy() if response == RESPONSE_ACCEPT: return True else: return False
def run(self): res = Dialog.run(self) if res == 1000: return "root" elif res == RESPONSE_ACCEPT: uname = self.uname_entry.get_text() return uname else: self.destroy() return "reject"
def input_entry_dialog(msg, default_answer="", parent=None): dia = Dialog( msg, parent, gtk.DIALOG_MODAL |gtk.DIALOG_DESTROY_WITH_PARENT, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, RESPONSE_OK) ) dia.vbox.pack_start(Label(msg)) da_entry = Entry() da_entry.set_text(default_answer) dia.vbox.pack_end( da_entry ) dia.show_all() result = dia.run() datext = da_entry.get_text() dia.destroy() return datext if result == RESPONSE_OK else None
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()