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