Changeset 4e9583c in sasview for guiframe/local_perspectives/plotting
- Timestamp:
- Jul 22, 2010 12:24:33 PM (15 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- cb463b4
- Parents:
- f5038c06
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/local_perspectives/plotting/plotting.py
rcb19af9f r4e9583c 15 15 import sys 16 16 from sans.guicomm.events import EVT_NEW_PLOT 17 from sans.guicomm.events import NewPlotEvent18 from sans.guicomm.events import EVT_NEW_LOADED_DATA19 17 from sans.guicomm.events import StatusEvent 20 18 21 19 22 class PlottingDialog(wx.Dialog):23 """24 Dialog to display plotting option25 """26 def __init__(self, parent=None, panel_on_focus=None, list_of_data=[]):27 """28 """29 wx.Dialog.__init__(self, parent=parent,title="Plotting", size=(300, 280))30 self.parent = parent31 self.panel_on_focus = panel_on_focus32 self.list_of_data = list_of_data33 self.define_structure()34 self.layout_plot_on_panel(list_of_data=self.list_of_data)35 self.layout_data_name(list_of_data=self.list_of_data)36 self.layout_button()37 38 def define_structure(self):39 """40 """41 #Dialog interface42 vbox = wx.BoxSizer(wx.VERTICAL)43 self.sizer_data = wx.BoxSizer(wx.HORIZONTAL)44 45 self.sizer_selection = wx.BoxSizer(wx.VERTICAL)46 self.sizer_button = wx.BoxSizer(wx.HORIZONTAL)47 vbox.Add(self.sizer_data)48 vbox.Add(self.sizer_selection)49 vbox.Add(self.sizer_button)50 self.SetSizer(vbox)51 self.Centre()52 53 def layout_button(self):54 """55 """56 self.bt_ok = wx.Button(self, wx.NewId(), "Ok", (30, 10))57 self.bt_ok.SetToolTipString("plot data")58 wx.EVT_BUTTON(self, self.bt_ok.GetId(), self.on_ok)59 60 self.sizer_button.AddMany([((40,40), 0,61 wx.LEFT|wx.ADJUST_MINSIZE, 100 ),62 (self.bt_ok, 0, wx.ALL,10)])63 64 def layout_data_name(self, list_of_data=[]):65 """66 """67 self.data_tcl = wx.TextCtrl(self, -1,size=(260,80), style=wx.TE_MULTILINE)68 hint_data = "Data to plot."69 self.data_tcl.SetToolTipString(hint_data)70 self.data_tcl.SetEditable(False)71 for item in list_of_data:72 self.data_tcl.AppendText(item.name+"\n")73 74 self.sizer_data.AddMany([(self.data_tcl, 1, wx.ALL, 10)])75 76 def layout_plot_on_panel(self, list_of_data=[]):77 """78 """79 if len(list_of_data) == 0:80 return81 elif len(list_of_data) ==1:82 self.layout_single_data(list_of_data=list_of_data)83 else:84 self.layout_multiple(list_of_data=list_of_data)85 86 def layout_single_data(self, list_of_data=[]):87 """88 """89 self.sizer_selection.Clear(True)90 if self.panel_on_focus is None and list_of_data < 1:91 return92 else:93 name = "Plot data on new panel"94 self.rb_single_data_panel = wx.RadioButton(self, -1,name,95 style=wx.RB_GROUP)96 msg = "Each data will be plotted separately on a new panel"97 self.rb_single_data_panel.SetToolTipString(msg)98 self.rb_single_data_panel.SetValue(True)99 self.Bind(wx.EVT_RADIOBUTTON, self.on_choose_panel,100 id=self.rb_single_data_panel.GetId())101 self.rb_panel_on_focus = wx.RadioButton(self, -1,"No Panel on Focus")102 msg = "All Data will be appended to panel on focus"103 self.rb_panel_on_focus.SetToolTipString(msg)104 self.rb_panel_on_focus.Disable()105 self.Bind(wx.EVT_RADIOBUTTON, self.on_choose_panel,106 id=self.rb_panel_on_focus.GetId())107 if self.panel_on_focus is not None:108 self.rb_panel_on_focus.Enable()109 self.rb_panel_on_focus.SetLabel(str(panel.window_name))110 self.sizer_selection.AddMany([(self.rb_single_data_panel,111 1, wx.ALL, 10),112 (self.rb_panel_on_focus,1, wx.ALL, 10)])113 114 def layout_multiple(self, list_of_data=[]):115 """116 """117 self.sizer_selection.Clear(True)118 if self.panel_on_focus is None and list_of_data <= 1:119 return120 name = "Plot each data separately"121 self.rb_single_data_panel = wx.RadioButton(self, -1,name,122 style=wx.RB_GROUP)123 msg = "Each data will be plotted separately on a new panel"124 self.rb_single_data_panel.SetToolTipString(msg)125 self.rb_single_data_panel.SetValue(True)126 self.Bind(wx.EVT_RADIOBUTTON, self.on_choose_panel,127 id=self.rb_single_data_panel.GetId())128 name = "Append all to new panel"129 self.rb_new_panel = wx.RadioButton(self, -1,name)130 msg = "All Data will be appended to a new panel"131 self.rb_new_panel.SetToolTipString(msg)132 self.Bind(wx.EVT_RADIOBUTTON, self.on_choose_panel,133 id=self.rb_new_panel.GetId())134 self.rb_panel_on_focus = wx.RadioButton(self, -1,"No Panel on Focus")135 msg = "All Data will be appended to panel on focus"136 self.rb_panel_on_focus.SetToolTipString(msg)137 self.rb_panel_on_focus.Disable()138 self.Bind(wx.EVT_RADIOBUTTON, self.on_choose_panel,139 id=self.rb_panel_on_focus.GetId())140 if self.panel_on_focus is not None:141 self.rb_panel_on_focus.Enable()142 self.rb_panel_on_focus.SetLabel(str(panel.window_name))143 144 self.sizer_selection.AddMany([(self.rb_single_data_panel,145 1, wx.LEFT|wx.RIGHT|wx.BOTTOM, 10),146 (self.rb_new_panel, 1, wx.LEFT|wx.RIGHT|wx.BOTTOM, 10),147 (self.rb_panel_on_focus, 1, wx.LEFT|wx.RIGHT|wx.BOTTOM, 10),])148 def on_ok(self, event):149 """150 """151 def on_choose_panel(self, event):152 """153 """154 20 class Plugin: 155 21 """ … … 196 62 self.parent = parent 197 63 # Connect to plotting events 198 self.parent.Bind(EVT_NEW_LOADED_DATA, self._on_plot)199 64 self.parent.Bind(EVT_NEW_PLOT, self._on_plot_event) 200 65 # We have no initial panels for this plug-in … … 227 92 pass 228 93 229 def _on_plot(self, event): 230 """ 231 check the contains of event. 232 if it is a list of data to plot plot each one at the time 233 """ 234 list_of_data1d = [] 235 if hasattr(event, "plots"): 236 for plot, path in event.plots: 237 print "plotting _on_plot" 238 if plot.__class__.__name__ == "Data2D": 239 wx.PostEvent(self.parent, 240 NewPlotEvent(plot=plot, title=plot.name)) 241 else: 242 list_of_data1d.append((plot, path)) 243 wx.PostEvent(self.parent, 244 NewPlotEvent(plot=plot, title=plot.name)) 245 94 246 95 def _on_plot_event(self, event): 247 96 """ … … 329 178 return 330 179 331 class Data(object):332 def __init__(self, name):333 self.name = str(name)334 class MyApp(wx.App):335 def OnInit(self):336 wx.InitAllImageHandlers()337 list =[Data(name="Data1D")]#,338 # Data(name="Data2D"),Data(name="Data3D")]339 dialog = PlottingDialog(list_of_data=list)340 if dialog.ShowModal() == wx.ID_OK:341 pass342 dialog.Destroy()343 344 return 1345 346 # end of class MyApp347 348 if __name__ == "__main__":349 app = MyApp(0)350 app.MainLoop()
Note: See TracChangeset
for help on using the changeset viewer.