source: sasview/sansview/perspectives/fitting/hint_fitpage.py @ 9e2cfee

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 9e2cfee was 4f81342, checked in by Gervaise Alina <gervyh@…>, 14 years ago

working on guiframe loading data for fitting

  • Property mode set to 100644
File size: 3.7 KB
Line 
1
2import os 
3import wx
4from wx.lib.scrolledpanel import ScrolledPanel
5from sans.guicomm.events import NewPlotEvent
6
7class HintFitPage(ScrolledPanel):
8    """
9    This class provide general structure of  fitpanel page
10    """
11     ## Internal name for the AUI manager
12    window_name = "Loaded Data"
13    ## Title to appear on top of the window
14    window_caption = "Loaded Data"
15   
16    def __init__(self, parent):
17        """
18        """
19        ScrolledPanel.__init__(self, parent,
20                 style=wx.FULL_REPAINT_ON_RESIZE)
21        self.SetupScrolling()
22        self.parent = parent
23        self.manager = None
24        msg = "right click on the data when it is highlighted "
25        msg += "the select option to fit for futher options"
26        self.do_layout()
27       
28    def set_manager(self, manager):
29        """
30        """
31        self.manager = manager
32       
33    def set_data(self, list=[], state=None):
34        """
35        """
36        if not list:
37            return 
38        for data, path in list:
39            if data.name not in self.data_cbbox.GetItems():
40                self.data_cbbox.Insert(item=data.name, pos=0,
41                                    clientData=(data, path))
42     
43        if self.data_cbbox.GetCount() ==1:
44            self.data_cbbox.SetSelection(0)
45            self.data_cbbox.Enable()
46            self.on_select_data(event=None)
47       
48    def do_layout(self):
49        """
50        Draw the page
51        """
52        self.vbox = wx.BoxSizer(wx.VERTICAL)
53        sizer1 = wx.BoxSizer(wx.HORIZONTAL)
54        sizer2 = wx.GridBagSizer(0,0)
55        box_description = wx.StaticBox(self, -1, "Hint")
56        boxsizer = wx.StaticBoxSizer(box_description, wx.HORIZONTAL)
57        boxsizer.SetMinSize((450,100))
58        msg  = "    How to link data to the control panel: \n \n"
59        msg += "    First load data file from 'File' menu. \n"
60        msg += "    Then Highlight and right click on the data plot. \n"
61        msg += "    Finally, select 'Select data for fitting' in the pop-up menu. \n"
62        self.hint_txt = wx.StaticText(self, -1, msg, style=wx.ALIGN_LEFT)
63        self.data_txt = wx.StaticText(self, -1,"Loaded Data: ")
64        self.data_cbbox = wx.ComboBox(self, -1, size=(260,20))
65        self.data_cbbox.Disable()
66        wx.EVT_COMBOBOX(self.data_cbbox ,-1, self.on_select_data) 
67       
68        sizer1.Add(self.hint_txt)
69        ix = 0 
70        iy = 0
71     
72        sizer2.Add(self.data_txt, (iy, ix), (1,1),
73                    wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
74        ix += 1
75        sizer2.Add( self.data_cbbox, (iy, ix), (1,1),
76                    wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
77        boxsizer.Add(sizer1)
78       
79        self.vbox.Add(boxsizer,0, wx.ALL, 10)
80        self.vbox.Add(sizer2)
81        self.SetSizer(self.vbox)
82       
83    def on_select_data(self, event=None):
84        """
85        """
86        n = self.data_cbbox.GetCurrentSelection()
87        data, path = self.data_cbbox.GetClientData(n)
88        if data.__class__.__name__ in ["Data1D", "Theory1D"]:
89            data = self.manager.create_fittable_data1D(data=data)
90        else:
91            data = self.manager.create_fittable_data2D(data=data)
92        self.parent.manager.add_fit_page(data=data)
93        if data !=None:
94            if hasattr(data,"title"):
95                title = str(data.title.lstrip().rstrip())
96                if title == "":
97                    title = str(data.name)
98            else:
99                title = str(data.name)
100            wx.PostEvent(self.parent.parent, NewPlotEvent(plot=data, title=title))
101       
102    def createMemento(self):
103        """
104        """
105        return 
106 
Note: See TracBrowser for help on using the repository browser.