Author: bugman Date: Wed Dec 22 09:56:24 2010 New Revision: 11934 URL: http://svn.gna.org/viewcvs/relax?rev=11934&view=rev Log: The mol, res, spin container window is now properly cleared each time a new tree item is selected. Modified: branches/bieri_gui/gui_bieri/components/spin_view.py Modified: branches/bieri_gui/gui_bieri/components/spin_view.py URL: http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/components/spin_view.py?rev=11934&r1=11933&r2=11934&view=diff ============================================================================== --- branches/bieri_gui/gui_bieri/components/spin_view.py (original) +++ branches/bieri_gui/gui_bieri/components/spin_view.py Wed Dec 22 09:56:24 2010 @@ -59,16 +59,49 @@ self.main_sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(self.main_sizer) + # Init the sizer content list. + self.sizer_items = [] + # Display the root window. self.display_root() + def add_item(self, item): + """Add the given item to the main sizer, and keep track of it. + + @param item: The item to add to the main sizer. + @type item: wx object + """ + + # Add to the sizer. + self.main_sizer.Add(item) + + # Append it to the sizer list. + self.sizer_items.append(item) + + + def clear(self): + """Clear the contents of the window.""" + + # Loop over the sizer items, destroying them. + for item in self.sizer_items: + item.Destroy() + + # Reset the sizer content list. + self.sizer_items = [] + + def display(self, info): """Display the info for the selected container. @param info: The information list consisting of the container type ('root', 'mol', 'res', or 'spin'), the molecule name, the residue number, the residue name, the spin number, and the spin name. The name and number information is dropped when not needed. @type info: list of str and int """ + + print "Displaying %s" % info + + # Destroy all the original contents. + self.clear() # The root window display. if info == 'root': @@ -94,7 +127,7 @@ text = wx.StaticText(self, -1, "The spin view window", (5,5)) # Add to the sizer. - self.main_sizer.Add(text) + self.add_item(text) def mol_container(self, mol_name=None): @@ -108,7 +141,7 @@ text = wx.StaticText(self, -1, "The molecule container", (5,5)) # Add to the sizer. - self.main_sizer.Add(text) + self.add_item(text) def res_container(self, mol_name=None, res_num=None, res_name=None): @@ -126,7 +159,7 @@ text = wx.StaticText(self, -1, "The residue container", (5,5)) # Add to the sizer. - self.main_sizer.Add(text) + self.add_item(text) def spin_container(self, mol_name=None, res_num=None, res_name=None, spin_num=None, spin_name=None): @@ -148,7 +181,7 @@ text = wx.StaticText(self, -1, "The spin container", (5,5)) # Add to the sizer. - self.main_sizer.Add(text) + self.add_item(text)