1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 __id__ = "$Id: phasenotebookpanel.py 2980 2009-04-02 00:14:33Z juhas $"
24
25 import wx
26
27 from diffpy.pdfgui.gui.pdfpanel import PDFPanel
28
29 from diffpy.pdfgui.gui.phaseconfigurepanel import PhaseConfigurePanel
30 from diffpy.pdfgui.gui.phaseconstraintspanel import PhaseConstraintsPanel
31 from diffpy.pdfgui.gui.phaseresultspanel import PhaseResultsPanel
32
33
34
37 PDFPanel.__init__(self)
38 kwds["style"] = wx.TAB_TRAVERSAL
39 wx.Panel.__init__(self, *args, **kwds)
40 self.notebook_phase = wx.Notebook(self, -1, style=0)
41 self.notebook_phase_pane_Configure = PhaseConfigurePanel(self.notebook_phase, -1)
42 self.notebook_phase_pane_Constraints = PhaseConstraintsPanel(self.notebook_phase, -1)
43 self.notebook_phase_pane_Results = PhaseResultsPanel(self.notebook_phase, -1)
44
45 self.__set_properties()
46 self.__do_layout()
47
48 self.notebook_phase.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.onNotebookPageChanged )
49 self.notebook_phase.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING, self.onNotebookPageChanging )
50
51 self.configuration = None
52 self.constraints = {}
53 self.results = None
54 self.mainFrame = None
55 self.focusedId = 0
56
57
60
61
63 sizer_1 = wx.BoxSizer(wx.HORIZONTAL)
64 self.notebook_phase.AddPage(self.notebook_phase_pane_Configure, "Configure")
65 self.notebook_phase.AddPage(self.notebook_phase_pane_Constraints, "Constraints")
66 self.notebook_phase.AddPage(self.notebook_phase_pane_Results, "Results")
67 sizer_1.Add(self.notebook_phase, 1, wx.EXPAND, 0)
68 self.SetAutoLayout(True)
69 self.SetSizer(sizer_1)
70 sizer_1.Fit(self)
71 sizer_1.SetSizeHints(self)
72
73
75 """Refreshes the currently shown panel."""
76 if self.mainFrame.quitting: return
77 if self.focusedId is -1: return
78
79 panel = self.notebook_phase.GetPage(self.focusedId)
80
81 panel.structure = self.configuration
82 panel.constraints = self.constraints
83 panel.results = self.results
84
85
86
87 panel.mainFrame = self.mainFrame
88 panel.refresh()
89 return
90
92 """Called during the page selection change."""
93 focusedId = event.GetOldSelection()
94 panel = self.notebook_phase.GetPage(self.focusedId)
95 panel._cache()
96 return
97
98 - def onNotebookPageChanged(self, event):
99 """Called after the page selection is changed."""
100 self.focusedId = event.GetSelection()
101 self.refresh()
102 event.Skip()
103 return
104
105
106 - def Enable(self, enable = True):
107 """Keep the notebook enabled, just not the panels."""
108 self.notebook_phase_pane_Configure.Enable(enable)
109 self.notebook_phase_pane_Constraints.Enable(enable)
110 self.notebook_phase_pane_Results.Enable(enable)
111 return
112
113
114
115
116
117 if __name__ == "__main__":
120 kwds["style"] = wx.DEFAULT_FRAME_STYLE
121 wx.Frame.__init__(self, *args, **kwds)
122 self.window = PhaseNotebookPanel(self, -1)
123 self.SetTitle("testing")
124
125 self.window.mainFrame = self.window
126 self.window.mainFrame.needsSave = self.dummy
127
128
129 self.window.treeCtrlMain = self.window
130 self.window.treeCtrlMain.GetSelections = self.dummy_dict
131
132 self.test()
133
134
135 - def dummy(self, *args, **kwds):
137
140
143
144
146 '''Testing code goes here'''
147 from diffpy.Structure.PDFFitStructure import PDFFitStructure
148 from diffpy.pdfgui.control.constraint import Constraint
149
150 self.window.configuration = PDFFitStructure()
151 self.window.configuration.read('../../tests/testdata/LaMnO3.pdb')
152 self.window.results = PDFFitStructure()
153 self.window.results.read('../../tests/testdata/LaMnO3.pdb')
154
155 formulas =['@1','@45','23+@3','@5 / 2',' @6 ', 'sin(@5)', '12+2*sqrt(@4)',' cos( @9 ) ','(@9*@9)','@10*2', '@6+@1']
156 self.window.constraints = {}
157
158 for i in xrange( len(self.window.notebook_phase_pane_Constraints.lConstraints) ):
159 self.window.constraints[self.window.notebook_phase_pane_Constraints.lConstraints[i]] = Constraint(formulas[i])
160
161 for i in xrange(len(self.window.notebook_phase_pane_Constraints.lAtomConstraints)):
162 key = self.window.notebook_phase_pane_Constraints.lAtomConstraints[i] + '('+`i+1`+')'
163 self.window.constraints[key] = Constraint(formulas[i])
164
165 self.window.refresh()
166
167
168
171 wx.InitAllImageHandlers()
172 frame_1 = MyFrame(None, -1, "")
173 self.SetTopWindow(frame_1)
174 frame_1.Show()
175 return 1
176
177 app = MyApp(0)
178 app.MainLoop()
179
180