Author: bugman Date: Mon Dec 13 11:08:29 2010 New Revision: 11768 URL: http://svn.gna.org/viewcvs/relax?rev=11768&view=rev Log: Created a rudimentary and not yet functional molecule.delete user function window. Modified: branches/bieri_gui/gui_bieri/menu.py branches/bieri_gui/gui_bieri/user_functions/molecule.py Modified: branches/bieri_gui/gui_bieri/menu.py URL: http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/menu.py?rev=11768&r1=11767&r2=11768&view=diff ============================================================================== --- branches/bieri_gui/gui_bieri/menu.py (original) +++ branches/bieri_gui/gui_bieri/menu.py Mon Dec 13 11:08:29 2010 @@ -192,7 +192,8 @@ # The list of entries to build. entries = [ [id_base + 000, "&molecule", paths.icon_16x16.molecule, None, [ - [id_base + 001, "&add", paths.icon_16x16.add, self.gui.user_functions.molecule.add] + [id_base + 001, "&add", paths.icon_16x16.add, self.gui.user_functions.molecule.add], + [id_base + 002, "&delete", paths.icon_16x16.cancel, self.gui.user_functions.molecule.delete] ]], [id_base + 100, "&pipe", paths.icon_16x16.load, None, [ [id_base + 101, "&create", paths.icon_16x16.add, self.gui.user_functions.pipes.create] Modified: branches/bieri_gui/gui_bieri/user_functions/molecule.py URL: http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/user_functions/molecule.py?rev=11768&r1=11767&r2=11768&view=diff ============================================================================== --- branches/bieri_gui/gui_bieri/user_functions/molecule.py (original) +++ branches/bieri_gui/gui_bieri/user_functions/molecule.py Mon Dec 13 11:08:29 2010 @@ -27,7 +27,8 @@ import wx # relax module imports. -from generic_fns.mol_res_spin import ALLOWED_MOL_TYPES +from generic_fns.mol_res_spin import ALLOWED_MOL_TYPES, molecule_loop +from generic_fns import pipes # GUI module imports. from base import UF_base, UF_window @@ -43,6 +44,7 @@ # The dialogs. self._add_window = Add_window(self.gui, self.interpreter) + self._delete_window = Delete_window(self.gui, self.interpreter) def add(self, event): @@ -55,10 +57,21 @@ self._add_window.Show() + def delete(self, event): + """The molecule.delete user function. + + @param event: The wx event. + @type event: wx event + """ + + self._delete_window.Show() + + def destroy(self): """Close all windows.""" self._add_window.Destroy() + class Add_window(UF_window): @@ -118,3 +131,61 @@ # Set the name. self.interpreter.molecule.create(mol_name=mol_name, type=self.mol_type) + + + +class Delete_window(UF_window): + """The molecule.delete() user function window.""" + + # Some class variables. + size_x = 600 + size_y = 400 + frame_title = 'Delete a molecule' + image_path = WIZARD_IMAGE_PATH + 'molecule.png' + main_text = 'This dialog allows you to delete molecules from the relax data store. The molecule will be deleted from the current data pipe.' + title = 'Molecule deletion' + + # Some private class variables. + _spacing = 20 + + + def _evt_mol_sel(self, event): + """Select the molecule. + + @param event: The wx event. + @type event: wx event + """ + + # Store the choice. + self.mol = str(event.GetString()) + + + def add_uf(self, sizer): + """Add the molecule specific GUI elements. + + @param sizer: A sizer object. + @type sizer: wx.Sizer instance + """ + + # Spacer. + sizer.AddSpacer(self._spacing) + + # The type selection. + names = [] + if pipes.cdp_name(): + for mol in molecule_loop(): + names.append(mol.name) + self.chooser(sizer, "The molecule:", self._evt_mol_sel, names) + + # Spacer. + sizer.AddSpacer(self._spacing) + + + def execute(self): + """Execute the user function.""" + + # The molecule ID. + id = '#' + self.mol + + # Delete the molecule. + self.interpreter.molecule.delete(mol_id=id)