Author: bugman Date: Fri Jul 1 16:24:06 2011 New Revision: 13371 URL: http://svn.gna.org/viewcvs/relax?rev=13371&view=rev Log: Created the structure.write_pdb user function window and menu entry. Modified: branches/gui_testing/gui/menu.py branches/gui_testing/gui/user_functions/structure.py Modified: branches/gui_testing/gui/menu.py URL: http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/menu.py?rev=13371&r1=13370&r2=13371&view=diff ============================================================================== --- branches/gui_testing/gui/menu.py (original) +++ branches/gui_testing/gui/menu.py Fri Jul 1 16:24:06 2011 @@ -231,7 +231,8 @@ ]], [wx.NewId(), "s&tructure", paths.icon_16x16.structure, None, [ [wx.NewId(), "&delete", paths.icon_16x16.remove, self.gui.user_functions.structure.delete], - [wx.NewId(), "read_&pdb", paths.icon_16x16.open, self.gui.user_functions.structure.read_pdb] + [wx.NewId(), "&read_pdb", paths.icon_16x16.open, self.gui.user_functions.structure.read_pdb], + [wx.NewId(), "&write_pdb", paths.icon_16x16.save, self.gui.user_functions.structure.write_pdb] ]], [wx.NewId(), "&value", paths.icon_16x16.value, None, [ [wx.NewId(), "&set", paths.icon_16x16.add, self.gui.user_functions.value.set] Modified: branches/gui_testing/gui/user_functions/structure.py URL: http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/user_functions/structure.py?rev=13371&r1=13370&r2=13371&view=diff ============================================================================== --- branches/gui_testing/gui/user_functions/structure.py (original) +++ branches/gui_testing/gui/user_functions/structure.py Fri Jul 1 16:24:06 2011 @@ -67,6 +67,22 @@ # Create the wizard. wizard = Wiz_window(size_x=800, size_y=600, title='PDB reader') page = Read_pdb_page(wizard, self.gui, self.interpreter) + wizard.add_page(page) + + # Execute the wizard. + wizard.run() + + + def write_pdb(self, event): + """The structure.write_pdb user function. + + @param event: The wx event. + @type event: wx event + """ + + # Create the wizard. + wizard = Wiz_window(size_x=800, size_y=600, title='PDB writer') + page = Write_pdb_page(wizard, self.gui, self.interpreter) wizard.add_page(page) # Execute the wizard. @@ -158,3 +174,39 @@ # Execute the user function. self.interpreter.structure.read_pdb(file=file, read_mol=read_mol, set_mol_name=set_mol_name, read_model=read_model, set_model_num=set_model_num, parser=parser) + + + +class Write_pdb_page(UF_page): + """The structure.write_pdb() user function page.""" + + # Some class variables. + image_path = WIZARD_IMAGE_PATH + sep + 'structure' + sep + 'write_pdb.png' + main_text = """ + """ + title = 'PDB writing' + + + def add_contents(self, sizer): + """Add the structure specific GUI elements. + + @param sizer: A sizer object. + @type sizer: wx.Sizer instance + """ + + # Add a file selection. + self.file = self.file_selection(sizer, "The PDB file:", title="PDB file selection") + + # The model_num arg. + self.model_num = self.input_field(sizer, "Only write model number:", tooltip="This is the 'model_num' user function argument.") + + + def on_execute(self): + """Execute the user function.""" + + # The args. + file = gui_to_str(self.file.GetValue()) + model_num = gui_to_str(self.model_num.GetValue()) + + # Execute the user function. + self.interpreter.structure.write_pdb(file=file, model_num=model_num)