Author: bugman Date: Mon Aug 8 19:33:57 2011 New Revision: 14273 URL: http://svn.gna.org/viewcvs/relax?rev=14273&view=rev Log: The results viewer window has now been separated from the analysis GUI code. This viewer will soon operation on a per-pipe basis as the spin viewer window does. Added: branches/gui_testing/gui/results_viewer.py - copied, changed from r14262, branches/gui_testing/gui/analyses/results.py Removed: branches/gui_testing/gui/analyses/results.py Modified: branches/gui_testing/gui/analyses/__init__.py branches/gui_testing/gui/analyses/execute.py branches/gui_testing/gui/menu.py branches/gui_testing/gui/relax_gui.py Modified: branches/gui_testing/gui/analyses/__init__.py URL: http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/analyses/__init__.py?rev=14273&r1=14272&r2=14273&view=diff ============================================================================== --- branches/gui_testing/gui/analyses/__init__.py (original) +++ branches/gui_testing/gui/analyses/__init__.py Mon Aug 8 19:33:57 2011 @@ -39,7 +39,6 @@ from gui.analyses.auto_noe import Auto_noe from gui.analyses.auto_r1 import Auto_r1 from gui.analyses.auto_r2 import Auto_r2 -from gui.analyses.results import Results_viewer from gui.analyses.wizard import Analysis_wizard from gui.message import error_message, Question @@ -78,9 +77,6 @@ # The analyses page objects. self._analyses = [] - - # Create the results viewer window. - self.results_viewer = Results_viewer(gui=self.gui) # Register the page switch method for pipe switches. self.name = 'notebook page switcher' @@ -571,18 +567,6 @@ self.gui.add_start_screen() - def show_results_viewer(self, event): - """Display the analysis results. - - @param event: The wx event. - @type event: wx event - """ - - # Open the window. - if status.show_gui: - self.results_viewer.Show() - - def switch_page(self, index): """Switch to the given page. Modified: branches/gui_testing/gui/analyses/execute.py URL: http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/analyses/execute.py?rev=14273&r1=14272&r2=14273&view=diff ============================================================================== --- branches/gui_testing/gui/analyses/execute.py (original) +++ branches/gui_testing/gui/analyses/execute.py Mon Aug 8 19:33:57 2011 @@ -104,8 +104,7 @@ # Display the results viewer. if self.results_display: - wx.CallAfter(self.gui.analysis.results_viewer.update_window, None) - wx.CallAfter(self.gui.analysis.show_results_viewer, None) + wx.CallAfter(self.gui.show_results_viewer, None) def run_analysis(self): Removed: branches/gui_testing/gui/analyses/results.py URL: http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/analyses/results.py?rev=14272&view=auto ============================================================================== --- branches/gui_testing/gui/analyses/results.py (original) +++ branches/gui_testing/gui/analyses/results.py (removed) @@ -1,256 +1,0 @@ -############################################################################### -# # -# Copyright (C) 2010 Michael Bieri # -# Copyright (C) 2011 Edward d'Auvergne # -# # -# This file is part of the program relax. # -# # -# relax is free software; you can redistribute it and/or modify # -# it under the terms of the GNU General Public License as published by # -# the Free Software Foundation; either version 2 of the License, or # -# (at your option) any later version. # -# # -# relax is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU General Public License for more details. # -# # -# You should have received a copy of the GNU General Public License # -# along with relax; if not, write to the Free Software # -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# # -############################################################################### - -# Module docstring. -"""Module containing the base class for the results frame.""" - -# Python module imports. -from string import upper -import wx -from wx.lib import buttons - -# relax module imports. -from data import Relax_data_store; ds = Relax_data_store() - -# relax GUI module imports. -from gui.analyses.results_analysis import see_results -from gui.fonts import font -from gui.icons import relax_icons -from gui.misc import add_border, gui_to_str, open_file, str_to_gui -from gui.paths import icon_22x22 - - -class Results_viewer(wx.Frame): - """The results viewer frame.""" - - # Some class variables. - border = 10 - size = (800, 400) - - def __init__(self, gui): - """Build the results frame. - - @param gui: The main GUI class. - @type gui: gui.relax_gui.Main instance - """ - - # Store the main class. - self.gui = gui - - # Initialise the base frame. - wx.Frame.__init__(self, parent=gui, style=wx.DEFAULT_FRAME_STYLE) - - # Set up the window icon. - self.SetIcons(relax_icons) - - # Set the window title, size, etc. - self.SetTitle("Results viewer") - self.SetSize(self.size) - - # Pack a sizer into the panel. - box_main = wx.BoxSizer(wx.HORIZONTAL) - self.SetSizer(box_main) - - # Build the central sizer, with borders. - box_centre = add_border(box_main, border=self.border, packing=wx.VERTICAL) - - # Build the analysis selector. - self.build_analysis_sel(box_centre) - - # Spacer. - box_centre.AddSpacer(self.border) - - # Add the list box. - self.list = self.add_list_box(box_centre, fn=None) - - # Spacer. - box_centre.AddSpacer(self.border) - - # Add the open button. - self.button_open = buttons.ThemedGenBitmapTextButton(self, -1, None, " Open") - self.button_open.SetBitmapLabel(wx.Bitmap(icon_22x22.document_open, wx.BITMAP_TYPE_ANY)) - self.button_open.SetFont(font.normal) - self.button_open.SetMinSize((103, 33)) - self.gui.Bind(wx.EVT_BUTTON, self.open_result_file, self.button_open) - box_centre.Add(self.button_open, 0, wx.ALIGN_RIGHT|wx.ADJUST_MINSIZE, 5) - - # Bind some events. - self.Bind(wx.EVT_LEFT_DOWN, self.update_choices, self.analysis_list) - self.Bind(wx.EVT_COMBOBOX, self.on_choice, self.analysis_list) - self.Bind(wx.EVT_CLOSE, self.handler_close) - - - def add_list_box(self, box, fn=None): - """Add a results list box. - - @param box: The box sizer to pack the box into. - @type box: wx.BoxSizer instance - @keyword fn: The function to bind double click events to. - @type fn: method - @return: The list box element. - @rtype: wx.ListBox element - """ - - # Initialise the list box. - list = wx.ListBox(self, -1, choices=[]) - - # Bind events. - self.gui.Bind(wx.EVT_LISTBOX_DCLICK, fn, list) - - # Add to the sizer. - box.Add(list, 1, wx.ALL|wx.EXPAND, 0) - - # Return the list box. - return list - - - def build_analysis_sel(self, box): - """Create the analysis selection element. - - @param box: The horizontal box element to pack the elements into. - @type box: wx.BoxSizer instance - """ - - # Use a horizontal packing of elements. - sizer = wx.BoxSizer(wx.HORIZONTAL) - - # The text. - label = wx.StaticText(self, -1, "Analysis selection") - - # The font and label properties. - label.SetFont(font.subtitle) - - # Add the label to the analysis box. - sizer.Add(label, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) - - # Add a spacer. - sizer.AddSpacer(self.border) - - # A combo box. - self.analysis_list = wx.ComboBox(self, -1, value='', style=wx.CB_DROPDOWN|wx.CB_READONLY, choices=[]) - self.analysis_list.SetMinSize((50, 27)) - sizer.Add(self.analysis_list, 1, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) - - # Add the analysis sizer to the main sizer. - box.Add(sizer, 0, wx.ALL|wx.EXPAND, 0) - - - def handler_close(self, event): - """Event handler for the close window action. - - @param event: The wx event. - @type event: wx event - """ - - # Close the window. - self.Hide() - - - def on_choice(self, event): - """Update the list of results on choosing an analysis. - - @param event: The wx event. - @type event: wx event - """ - - # Clear the list. - self.list.Clear() - - # Get the page corresponding to the choice. - page = self.gui.analysis.get_page_from_name(gui_to_str(self.analysis_list.GetValue())) - - # Nothing to do. - if not hasattr(cdp, 'result_files'): - return - - # Update the list. - for i in range(len(cdp.result_files)): - # The text to display. - text = "%s%s file: %s" % (upper(cdp.result_files[i][0][0]), cdp.result_files[i][0][1:], cdp.result_files[i][1]) - - # Add the text with the Python data. - self.list.Append(str_to_gui(text), clientData=cdp.result_files[i]) - - - def open_result_file(self, event): - """Open the results in the appropriate program. - - @param event: The wx event. - @type event: wx event - """ - - # No choice. - if self.list.GetSelection() == wx.NOT_FOUND: - return - - # Get the data. - data = self.list.GetClientData(self.list.GetSelection()) - - # Grace files. - if data[0] == 'grace': - self.gui.user_functions.grace.view(None, file=data[1]) - - # A special table. - elif data[0] == 'Table_of_Results': - # The data. - model_result = [ds.relax_gui.table_residue, ds.relax_gui.table_model, ds.relax_gui.table_s2, ds.relax_gui.table_rex, ds.relax_gui.table_te] - - # Open. - see_results(choice, model_result) - - # Open all other files in which ever editor the platform decides on. - else: - open_file(data[1]) - - - - def update_choices(self, event): - """Update the list of analyses. - - @param event: The wx event. - @type event: wx event - """ - - # Clear the previous analyses. - self.analysis_list.Clear() - - # The list of analyses. - for data in self.gui.analysis.analysis_data_loop(): - self.analysis_list.Append(str_to_gui(data.analysis_name)) - - # Set the name to the current analysis. - self.analysis_list.SetValue(str_to_gui(self.gui.analysis.current_analysis_name())) - - - def update_window(self, event=None): - """Update the window. - - @param event: The wx event. - @type event: wx event - """ - - # Update the choices. - self.update_choices(None) - - # Update the list. - self.on_choice(None) Modified: branches/gui_testing/gui/menu.py URL: http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/menu.py?rev=14273&r1=14272&r2=14273&view=diff ============================================================================== --- branches/gui_testing/gui/menu.py (original) +++ branches/gui_testing/gui/menu.py Mon Aug 8 19:33:57 2011 @@ -103,7 +103,7 @@ self.gui.Bind(wx.EVT_MENU, self.gui.show_controller, id=self.MENU_VIEW_CONTROLLER) self.gui.Bind(wx.EVT_MENU, self.gui.show_prompt, id=self.MENU_VIEW_PROMPT) self.gui.Bind(wx.EVT_MENU, self.gui.show_tree, id=self.MENU_VIEW_SPIN_VIEW) - self.gui.Bind(wx.EVT_MENU, self.gui.analysis.show_results_viewer, id=self.MENU_VIEW_RESULTS) + self.gui.Bind(wx.EVT_MENU, self.gui.show_results_viewer, id=self.MENU_VIEW_RESULTS) self.gui.Bind(wx.EVT_MENU, self.gui.show_pipe_editor, id=self.MENU_VIEW_PIPE_EDIT) # The 'User functions' menu entries. Modified: branches/gui_testing/gui/relax_gui.py URL: http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/relax_gui.py?rev=14273&r1=14272&r2=14273&view=diff ============================================================================== --- branches/gui_testing/gui/relax_gui.py (original) +++ branches/gui_testing/gui/relax_gui.py Mon Aug 8 19:33:57 2011 @@ -63,6 +63,7 @@ from gui.pipe_editor import Pipe_editor from gui.references import References from gui.relax_prompt import Prompt +from gui.results_viewer import Results_viewer from gui.settings import Free_file_format, load_sequence from gui.user_functions import User_functions @@ -434,6 +435,22 @@ self.relax_prompt.Show() + def show_results_viewer(self, event): + """Display the analysis results. + + @param event: The wx event. + @type event: wx event + """ + + # Create the results viewer window if needed. + if not hasattr(self, 'results_viewer'): + self.results_viewer = Results_viewer(gui=self) + + # Open the window. + if status.show_gui: + self.results_viewer.Show() + + def show_tree(self, event): """Display the molecule, residue, and spin tree window. Copied: branches/gui_testing/gui/results_viewer.py (from r14262, branches/gui_testing/gui/analyses/results.py) URL: http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/results_viewer.py?p2=branches/gui_testing/gui/results_viewer.py&p1=branches/gui_testing/gui/analyses/results.py&r1=14262&r2=14273&rev=14273&view=diff ============================================================================== --- branches/gui_testing/gui/analyses/results.py (original) +++ branches/gui_testing/gui/results_viewer.py Mon Aug 8 19:33:57 2011 @@ -31,9 +31,9 @@ # relax module imports. from data import Relax_data_store; ds = Relax_data_store() +from status import Status; status = Status() # relax GUI module imports. -from gui.analyses.results_analysis import see_results from gui.fonts import font from gui.icons import relax_icons from gui.misc import add_border, gui_to_str, open_file, str_to_gui @@ -100,6 +100,21 @@ self.Bind(wx.EVT_CLOSE, self.handler_close) + def Show(self, show=True): + """Change the behaviour of showing the window to update the content. + + @keyword show: A flag which is True shows the window. + @type show: bool + """ + + # Update the window. + self.update_window() + + # Show the window using the base class method. + if status.show_gui: + super(Results_viewer, self).Show(show) + + def add_list_box(self, box, fn=None): """Add a results list box. @@ -215,9 +230,6 @@ # The data. model_result = [ds.relax_gui.table_residue, ds.relax_gui.table_model, ds.relax_gui.table_s2, ds.relax_gui.table_rex, ds.relax_gui.table_te] - # Open. - see_results(choice, model_result) - # Open all other files in which ever editor the platform decides on. else: open_file(data[1])