1 | |
---|
2 | import os |
---|
3 | import wx |
---|
4 | from wx.lib.scrolledpanel import ScrolledPanel |
---|
5 | from sans.guicomm.events import NewPlotEvent |
---|
6 | |
---|
7 | class HintFitPage(ScrolledPanel): |
---|
8 | """ |
---|
9 | This class provide general structure of fitpanel page |
---|
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): |
---|
17 | """ |
---|
18 | """ |
---|
19 | ScrolledPanel.__init__(self, parent, |
---|
20 | style=wx.FULL_REPAINT_ON_RESIZE) |
---|
21 | self.SetupScrolling() |
---|
22 | self.parent = parent |
---|
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() |
---|
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) |
---|
41 | |
---|
42 | def do_layout(self): |
---|
43 | """ |
---|
44 | Draw the page |
---|
45 | """ |
---|
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)) |
---|
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" |
---|
56 | self.hint_txt = wx.StaticText(self, -1, msg, style=wx.ALIGN_LEFT) |
---|
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) |
---|
75 | self.SetSizer(self.vbox) |
---|
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) |
---|
83 | |
---|
84 | def createMemento(self): |
---|
85 | """ |
---|
86 | """ |
---|
87 | return |
---|
88 | |
---|