source: sasview/calculatorview/src/sans/perspectives/calculator/data_operator.py @ 1a98ded

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 1a98ded was 1a98ded, checked in by Jae Cho <jhjcho@…>, 12 years ago

another module for data operator

  • Property mode set to 100644
File size: 25.2 KB
Line 
1"""
2GUI for the data operation
3"""
4import wx
5import sys
6import time
7import numpy
8from sans.dataloader.data_info import Data2D
9from sans.dataloader.data_info import Data1D
10from danse.common.plottools.PlotPanel import PlotPanel
11from danse.common.plottools.plottables import Graph
12from danse.common.plottools.canvas import FigureCanvas
13from matplotlib.font_manager import FontProperties
14from matplotlib.figure import Figure
15from sans.guiframe.events import StatusEvent
16       
17#Control panel width
18if sys.platform.count("win32") > 0:
19    PANEL_WIDTH = 780
20    PANEL_HEIGTH = 370
21    FONT_VARIANT = 0
22    _BOX_WIDTH = 200
23    ON_MAC = False
24else:
25    _BOX_WIDTH = 230
26    PANEL_WIDTH = 890
27    PANEL_HEIGTH = 470
28    FONT_VARIANT = 1
29    ON_MAC = True
30     
31class DataOperPanel(wx.ScrolledWindow):
32    """
33    :param data: when not empty the class can
34                same information into a data object
35        and post event containing the changed data object to some other frame
36    """
37    def __init__(self, parent, *args, **kwds):
38        kwds['name'] = "Data Operation"
39        kwds["size"] = (PANEL_WIDTH, PANEL_HEIGTH)
40        wx.ScrolledWindow.__init__(self, parent, *args, **kwds)
41        self.parent = parent
42        #sizers etc.
43        self.main_sizer = None
44        self.name_sizer = None
45        self.button_sizer = None
46        self.data_namectr = None
47        self.numberctr = None
48        self.data1_cbox = None
49        self.operator_cbox = None
50        self.data2_cbox = None
51        self.data_title_tcl = None
52        self.out_pic = None
53        self.equal_pic = None
54        self.data1_pic = None
55        self.operator_pic = None
56        self.data2_pic = None
57        self.output = None
58        self._notes = None
59        #data
60        self._data = self.get_datalist()
61        self._do_layout()
62        self.fill_data_combox()
63        self.fill_oprator_combox()
64        self.Bind(wx.EVT_PAINT, self.set_panel_on_focus)
65             
66    def _define_structure(self):
67        """
68        define initial sizer
69        """
70        self.main_sizer = wx.BoxSizer(wx.VERTICAL)
71        title = "Data Operation "
72        title += "[ + (add); - (subtract); "
73        title += "* (multiply); / (divide); "
74        title += "| (append) ]"
75        name_box = wx.StaticBox(self, -1, title)
76        self.name_sizer = wx.StaticBoxSizer(name_box, wx.HORIZONTAL)
77        self.button_sizer = wx.BoxSizer(wx.HORIZONTAL)
78     
79    def _layout_name(self):
80        """
81        Do the layout for data name related widgets
82        """
83        new_data_sizer = wx.BoxSizer(wx.VERTICAL)
84        equal_sizer =  wx.BoxSizer(wx.VERTICAL)
85        old_data1_sizer = wx.BoxSizer(wx.VERTICAL)
86        operator_sizer = wx.BoxSizer(wx.VERTICAL)
87        old_data2_sizer = wx.BoxSizer(wx.VERTICAL)
88        data2_hori_sizer = wx.BoxSizer(wx.HORIZONTAL)
89        data_name = wx.StaticText(self, -1, 'Output Data Name') 
90        equal_name = wx.StaticText(self, -1, ' =',  size=(50, 23)) 
91        data1_name = wx.StaticText(self, -1, 'Data1')
92        operator_name = wx.StaticText(self, -1, 'Operator')
93        data2_name = wx.StaticText(self, -1, 'Data2 (or Number)')
94        self.data_namectr = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 25))
95        self.data_namectr.SetToolTipString("Hit 'Enter' key after typing.")
96        self.data_namectr.SetValue(str('MyNewDataName'))
97        self.numberctr = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/3, 25)) 
98        self.numberctr.SetToolTipString("Hit 'Enter' key after typing.")
99        self.numberctr.SetValue(str(1.0))
100        self.data1_cbox = wx.ComboBox(self, -1, size=(_BOX_WIDTH, 25), 
101                                      style=wx.CB_READONLY)
102        self.operator_cbox = wx.ComboBox(self, -1, size=(50, 25), 
103                                         style=wx.CB_READONLY)
104        operation_tip = "Add: +, Subtract: -, "
105        operation_tip += "Multiply: *, Divide: /, "
106        operation_tip += "Append(Combine): | "
107        self.operator_cbox.SetToolTipString(operation_tip)
108        self.data2_cbox = wx.ComboBox(self, -1, size=(_BOX_WIDTH*2/3, 25),
109                                       style=wx.CB_READONLY)
110
111        self.out_pic = SmallPanel(self, -1, True, size=(_BOX_WIDTH, _BOX_WIDTH), 
112                             style=wx.NO_BORDER)
113        self.equal_pic = SmallPanel(self, -1, True, '=',  size=(50, _BOX_WIDTH), 
114                              style=wx.NO_BORDER)
115        self.data1_pic = SmallPanel(self, -1, True, size=(_BOX_WIDTH, _BOX_WIDTH), 
116                             style=wx.NO_BORDER)
117        self.operator_pic = SmallPanel(self, -1, True, "+", size=(50, _BOX_WIDTH), 
118                             style=wx.NO_BORDER)
119        self.data2_pic = SmallPanel(self, -1, True, size=(_BOX_WIDTH, _BOX_WIDTH), 
120                             style=wx.NO_BORDER)
121        for ax in self.equal_pic.axes:
122            ax.set_frame_on(False)
123        for ax in self.operator_pic.axes:
124            ax.set_frame_on(False)
125
126        new_data_sizer.AddMany([(data_name, 0, wx.LEFT, 3),
127                                       (self.data_namectr, 0, wx.LEFT, 3),
128                                       (self.out_pic, 0, wx.LEFT, 3)])
129        equal_sizer.AddMany([(13, 15), (equal_name, 0, wx.LEFT, 3),
130                                       (self.equal_pic, 0, wx.LEFT, 3)])
131        old_data1_sizer.AddMany([(data1_name, 0, wx.LEFT, 3),
132                                       (self.data1_cbox, 0, wx.LEFT, 3),
133                                       (self.data1_pic, 0, wx.LEFT, 3)])
134        operator_sizer.AddMany([(operator_name, 0, wx.LEFT, 3),
135                                 (self.operator_cbox, 0, wx.LEFT, 3),
136                                 (self.operator_pic, 0, wx.LEFT, 3)])
137        data2_hori_sizer.AddMany([(self.data2_cbox, 0, wx.LEFT, 0),
138                                       (self.numberctr, 0, wx.LEFT, 0)])
139        old_data2_sizer.AddMany([(data2_name, 0, wx.LEFT, 3),
140                                       (data2_hori_sizer, 0, wx.LEFT, 3),
141                                       (self.data2_pic, 0, wx.LEFT, 3)])
142        self.name_sizer.AddMany([(new_data_sizer, 0, wx.LEFT|wx.TOP, 5),
143                                       (equal_sizer, 0, wx.TOP, 5),
144                                       (old_data1_sizer, 0, wx.TOP, 5),
145                                       (operator_sizer, 0, wx.TOP, 5),
146                                       (old_data2_sizer, 0, wx.TOP, 5)])
147        self.data2_cbox.Show(True)
148        self.numberctr.Hide()
149        wx.EVT_TEXT_ENTER(self.data_namectr, -1, self.on_name)
150        wx.EVT_TEXT_ENTER(self.numberctr, -1, self.on_number) 
151        wx.EVT_COMBOBOX(self.data1_cbox, -1, self.on_select_data1) 
152        wx.EVT_COMBOBOX(self.operator_cbox, -1, self.on_select_operator) 
153        wx.EVT_COMBOBOX(self.data2_cbox, -1, self.on_select_data2)
154       
155    def on_name(self, event=None):
156        """
157        On data name typing
158        """
159        item = event.GetEventObject()
160        item.SetBackgroundColour('white')
161        text = item.GetLabel().strip()
162        self._check_newname(text)
163   
164    def _check_newname(self, name=None):
165        """
166        Check name ctr strings
167        """
168        self.send_warnings('')
169        msg = ''
170        if name == None:
171            text = self.data_namectr.GetLabel().strip()
172        else:
173            text = name
174        state_list = self.get_datalist().values()
175        if text in [str(state.data.name) for state in state_list]:
176            self.data_namectr.SetBackgroundColour('pink')
177            msg = "DataOperation: The name already exists."
178        if len(text) == 0:
179            self.data_namectr.SetBackgroundColour('pink')
180            msg = "DataOperation: Type the data name first."
181        if self._notes:
182            self.send_warnings(msg, 'error')
183        self.name_sizer.Layout()
184        self.Refresh()
185               
186    def on_number(self, event=None):
187        """
188        On selecting Number for Data2
189        """
190        self.send_warnings('')
191        self.numberctr.SetBackgroundColour('white')
192        item = event.GetEventObject()
193        text = item.GetLabel().strip()
194        try:
195            val = float(text)
196            pos = self.data2_cbox.GetSelection()
197            self.data2_cbox.SetClientData(pos, val)
198        except:
199            self.numberctr.SetBackgroundColour('pink')
200            msg = "DataOperation: Number requires a float number."
201            self.send_warnings(msg, 'error')
202            return
203        self.put_text_pic(self.data2_pic, content=str(val)) 
204        self.check_data_inputs()
205        if self.output != None:
206            self.output.name = str(self.data_namectr.GetValue())
207        self.draw_output(self.output)
208       
209    def on_select_data1(self, event=None):
210        """
211        On select data1
212        """
213        self.send_warnings('')
214        item = event.GetEventObject()
215        pos = item.GetSelection()
216        data = item.GetClientData(pos)
217        if data == None:
218            content = "?"
219            self.put_text_pic(self.data1_pic, content) 
220        else:
221            self.data1_pic.add_image(data)
222        self.check_data_inputs()
223        if self.output != None:
224            self.output.name = str(self.data_namectr.GetValue())
225        self.draw_output(self.output)
226       
227    def on_select_operator(self, event=None):
228        """
229        On Select an Operator
230        """
231        self.send_warnings('')
232        item = event.GetEventObject()
233        text = item.GetLabel().strip()
234        self.put_text_pic(self.operator_pic, content=text) 
235        self.check_data_inputs()
236        if self.output != None:
237            self.output.name = str(self.data_namectr.GetValue())
238        self.draw_output(self.output)
239       
240    def on_select_data2(self, event=None):
241        """
242        On Selecting Data2
243        """
244        self.send_warnings('')
245        item = event.GetEventObject()
246        text = item.GetLabel().strip().lower()
247        self.numberctr.Show(text=='number')
248        pos = item.GetSelection()
249        data = item.GetClientData(pos)
250        if not self.numberctr.IsShown():
251            if data == None:
252                content = "?"
253                self.put_text_pic(self.data2_pic, content) 
254            else:
255                self.data2_pic.add_image(data)
256        else:
257            if data == None:
258                content = str(self.numberctr.GetValue().strip())
259                try:
260                    content = float(content)
261                    data = content
262                except:
263                    content = "?"
264                    data = None
265                item.SetClientData(pos, content)
266            self.put_text_pic(self.data2_pic, content)   
267        self.check_data_inputs()
268
269        if self.output != None:
270            self.output.name = str(self.data_namectr.GetValue())
271        self.draw_output(self.output)
272   
273    def put_text_pic(self, pic=None, content=''): 
274        """
275        Put text to the pic
276        """
277        pic.set_content(content) 
278        pic.add_text()
279        pic.draw()
280                 
281    def check_data_inputs(self):
282        """
283        Check data1 and data2 whether or not they are ready for operation
284        """
285        self.data1_cbox.SetBackgroundColour('white')
286        self.data2_cbox.SetBackgroundColour('white')
287        flag = False
288        pos1 = self.data1_cbox.GetCurrentSelection()
289        data1 = self.data1_cbox.GetClientData(pos1)
290        if data1 == None:
291            self.output = None
292            return flag
293        pos2 = self.data2_cbox.GetCurrentSelection()
294        data2 = self.data2_cbox.GetClientData(pos2)
295        if data2 == None:
296            self.output = None
297            return flag
298        if self.numberctr.IsShown():
299            self.numberctr.SetBackgroundColour('white')
300            try:
301                float(data2)
302            except:
303                msg = "DataOperation: Number requires a float number."
304                self.send_warnings(msg, 'error')
305                self.numberctr.SetBackgroundColour('pink')
306                self.output = None
307                return flag
308        elif data1.__class__.__name__ != data2.__class__.__name__:
309            self.data1_cbox.SetBackgroundColour('pink')
310            self.data2_cbox.SetBackgroundColour('pink')
311            msg = "DataOperation: Data types must be same."
312            self.send_warnings(msg, 'error')
313            self.output = None
314            return flag
315        try:
316            self.output = self.make_data_out(data1, data2)
317        except:
318            self._check_newname()
319            self.data1_cbox.SetBackgroundColour('pink')
320            self.data2_cbox.SetBackgroundColour('pink')
321            msg = "DataOperation: Data types must be same."
322            self.send_warnings(msg, 'error')
323            self.output = None
324            return flag
325        return True
326   
327    def make_data_out(self, data1, data2):
328        """
329        Make a temp. data output set
330        """
331        output = None
332        pos = self.operator_cbox.GetCurrentSelection()
333        operator = self.operator_cbox.GetClientData(pos)
334        exec "output = data1 %s data2"% operator
335        return output
336   
337   
338    def draw_output(self, output):
339        """
340        Draw output data(temp)
341        """
342        out = self.out_pic
343        if output == None:
344            content = "?"
345            self.put_text_pic(out, content) 
346        else:
347            out.add_image(output)
348        self.name_sizer.Layout()
349        self.Refresh()
350                   
351    def _layout_button(self): 
352        """
353            Do the layout for the button widgets
354        """ 
355        self.bt_apply = wx.Button(self, -1, "Apply", size=(_BOX_WIDTH/2, -1))
356        app_tip = "Generate the Data and send to Data Explorer."
357        self.bt_apply.SetToolTipString(app_tip)
358        self.bt_apply.Bind(wx.EVT_BUTTON, self.on_click_apply)
359       
360        self.bt_close = wx.Button(self, -1, 'Close', size=(_BOX_WIDTH/2, -1))
361        self.bt_close.Bind(wx.EVT_BUTTON, self.on_close)
362        self.bt_close.SetToolTipString("Close this panel.")
363       
364        self.button_sizer.AddMany([(PANEL_WIDTH/2, 25),
365                                   (self.bt_apply, 0, wx.RIGHT, 10),
366                                   (self.bt_close, 0, wx.RIGHT, 10)])
367       
368    def _do_layout(self):
369        """
370        Draw the current panel
371        """
372        self._define_structure()
373        self._layout_name()
374        self._layout_button()
375        self.main_sizer.AddMany([(self.name_sizer, 0, wx.EXPAND|wx.ALL, 10),
376                                (self.button_sizer, 0,
377                                          wx.EXPAND|wx.TOP|wx.BOTTOM, 5)])
378        self.SetSizer(self.main_sizer)
379        self.SetScrollbars(20, 20, 25, 65)
380        self.SetAutoLayout(True)
381   
382    def set_panel_on_focus(self, event):
383        """
384        On Focus at this window
385        """
386        if event != None:
387            event.Skip()
388        children = self.GetChildren()
389        # update the list only when it is on the top
390        if self.FindFocus() in children:
391            self.fill_data_combox()
392         
393    def fill_oprator_combox(self):
394        """
395        fill the current combobox with the operator
396        """   
397        operator_list = [' +', ' -', ' *', " /", " |"]
398        for oper in operator_list:
399            pos = self.operator_cbox.Append(str(oper))
400            self.operator_cbox.SetClientData(pos, str(oper.strip()))
401        self.operator_cbox.SetSelection(0)
402       
403       
404    def fill_data_combox(self):
405        """
406        fill the current combobox with the available data
407        """
408        pos_pre1 = self.data1_cbox.GetCurrentSelection()
409        pos_pre2 = self.data2_cbox.GetCurrentSelection()
410        current1 = self.data1_cbox.GetLabel()
411        current2 = self.data2_cbox.GetLabel()
412        if pos_pre1 < 0:
413            pos_pre1 = 0
414        if pos_pre2 < 0:
415            pos_pre2 = 0
416        self.data1_cbox.Clear()
417        self.data2_cbox.Clear()
418        if not self._data:
419            pos = self.data1_cbox.Append('No Data Available')
420            self.data1_cbox.SetSelection(pos)
421            self.data1_cbox.SetClientData(pos, None)
422            pos2 = self.data2_cbox.Append('No Data Available')
423            self.data2_cbox.SetSelection(pos2)
424            self.data2_cbox.SetClientData(pos2, None)
425            pos3 = self.data2_cbox.Append("Number")
426            self.data2_cbox.SetClientData(pos3, None)
427            return
428        pos1 = self.data1_cbox.Append('Select Data')
429        self.data1_cbox.SetSelection(pos1)
430        self.data1_cbox.SetClientData(pos1, None)
431        pos2 = self.data2_cbox.Append('Select Data')
432        self.data2_cbox.SetSelection(pos2)
433        self.data2_cbox.SetClientData(pos2, None)
434        pos3 = self.data2_cbox.Append("Number")
435        self.data2_cbox.SetClientData(pos3, None)
436        dnames = [dstate.data.name for dstate in self._data.values()]
437        ind = numpy.argsort(dnames)
438        for datastate in numpy.array(self._data.values())[ind]:
439            data = datastate.data
440            if data != None:
441                name = data.name
442                pos1 = self.data1_cbox.Append(str(name))
443                self.data1_cbox.SetClientData(pos1, data)
444                pos2 = self.data2_cbox.Append(str(name))
445                self.data2_cbox.SetClientData(pos2, data)
446                if str(current1) == str(name):
447                  pos_pre1 = pos1
448                if str(current2) == str(name):
449                  pos_pre2 = pos2
450            try:
451                theory_list = datastate.get_theory()
452                for theory, _ in theory_list.values():
453                    th_name = theory.name
454                    posth1 = self.data1_cbox.Append(str(th_name))
455                    self.data1_cbox.SetClientData(posth1, theory)
456                    posth2 = self.data2_cbox.Append(str(th_name))
457                    self.data2_cbox.SetClientData(posth2, theory)
458                    if str(current1) == str(th_name):
459                        pos_pre1 = posth1
460                    if str(current2) == str(th_name):
461                        pos_pre2 = posth2
462            except:
463                continue 
464        self.data1_cbox.SetSelection(pos_pre1)
465        self.data2_cbox.SetSelection(pos_pre2)
466   
467    def get_datalist(self):
468        """
469        """
470        data_manager = self.parent.parent.get_data_manager()
471        if data_manager != None:
472            return  data_manager.get_all_data()
473        else:
474            return {}
475           
476    def on_click_apply(self, event):
477        """   
478        changes are saved in data object imported to edit
479        """
480        self.send_warnings('')
481        self.data_namectr.SetBackgroundColour('white')
482        state_list = self.get_datalist().values()
483        name = self.data_namectr.GetLabel().strip()
484        if name in [str(state.data.name) for state in state_list]:
485            self.data_namectr.SetBackgroundColour('pink')
486            msg = "The Output Data Name already exists...   "
487            wx.MessageBox(msg, 'Error')
488            return
489        if name == '':
490            self.data_namectr.SetBackgroundColour('pink')
491            msg = "Please type the output data name first...   "
492            wx.MessageBox(msg, 'Error')
493            return
494        if self.output == None:
495            msg = "No Output Data has been generated...   "
496            wx.MessageBox(msg, 'Error')
497            return
498        # send data to data manager
499        self.output.name = name
500        self.output.run = "Data Operation"
501        self.output.instrument = "SansView"
502        self.output.id = str(name) + str(time.time())
503        data = {self.output.id :self.output}
504        self.parent.parent.add_data(data)
505        self.name_sizer.Layout()
506        self.Refresh()
507        #must post event here
508        event.Skip()
509   
510    def on_close(self, event):
511        """
512        leave data as it is and close
513        """
514        self.parent.OnClose()
515       
516    def set_plot_unfocus(self):
517        """
518        Unfocus on right click
519        """
520   
521    def send_warnings(self, msg='', info=''):
522        """
523        Send warning to status bar
524        """
525        wx.PostEvent(self.parent.parent, StatusEvent(status=msg, info=info))
526         
527class SmallPanel(PlotPanel):
528    """
529    PlotPanel for Quick plot and masking plot
530    """
531    def __init__(self, parent, id=-1, is_number=False, content='?', **kwargs):
532        """
533        """ 
534        PlotPanel.__init__(self, parent, id=id, **kwargs)
535        self.is_number = is_number
536        self.content = content
537        self.position = (0.4, 0.5)
538        self.scale = 'linear'
539        self.subplot.set_xticks([])
540        self.subplot.set_yticks([])
541        self.add_text()
542        self.figure.subplots_adjust(left=0.1, bottom=0.1)
543       
544    def set_content(self, content=''):
545        """
546        Set text content
547        """
548        self.content = str(content)
549         
550    def add_toolbar(self):
551        """
552        Add toolbar
553        """
554        # Not implemented
555        pass
556   
557    def on_set_focus(self, event):
558        """
559        send to the parenet the current panel on focus
560        """
561        pass
562
563    def add_image(self, plot):
564        """
565        Add Image
566        """
567        self.content = ''
568        self.textList = []
569        self.plots = {}
570        self.clear()
571        try:
572            self.figure.delaxes(self.figure.axes[0])
573            self.subplot = self.figure.add_subplot(111)
574            #self.figure.delaxes(self.figure.axes[1])
575        except:
576            pass
577        try:
578            name = plot.name
579        except:
580            name = plot.filename
581        self.plots[name] = plot
582
583        #init graph
584        self.graph = Graph()
585
586        #add plot
587        self.graph.add(plot)
588        #draw       
589        self.graph.render(self)
590       
591        try:
592            self.figure.delaxes(self.figure.axes[1])
593        except:
594            pass
595        self.subplot.figure.canvas.resizing = False
596        self.subplot.set_xticks([])
597        self.subplot.set_yticks([])
598        # Draw zero axis lines
599        self.subplot.axhline(linewidth = 1, color='r') 
600        self.subplot.axvline(linewidth = 1, color='r')       
601
602        self.erase_legend()
603        self.figure.tight_layout()
604        self.figure.subplots_adjust(left=0.1, bottom=0.1)
605
606        self.subplot.figure.canvas.draw()
607
608    def add_text(self):
609        """
610        Text in the plot
611        """
612        if not self.is_number:
613            return
614
615        self.clear()
616        try:
617            self.figure.delaxes(self.figure.axes[0])
618            self.subplot = self.figure.add_subplot(111)
619            self.figure.delaxes(self.figure.axes[1])
620        except:
621            pass
622        self.subplot.set_xticks([])
623        self.subplot.set_yticks([])
624        label = self.content
625        FONT = FontProperties()
626        xpos, ypos = (0.4, 0.5)
627        font = FONT.copy()
628        font.set_size(14)
629
630        self.textList = []
631        self.subplot.set_xlim((0, 1))
632        self.subplot.set_ylim((0, 1))
633       
634        try:
635            if self.content != '?':
636                float(label)
637        except:
638            self.subplot.set_frame_on(False)
639        self.figure.tight_layout()#subplots_adjust(left=0.1, bottom=0.1)
640        self.figure.subplots_adjust(left=0.1, bottom=0.1)
641        if len(label) > 0 and xpos > 0 and ypos > 0:
642            new_text = self.subplot.text(str(xpos), str(ypos), str(label),
643                                           fontproperties=font)
644            self.textList.append(new_text) 
645       
646    def erase_legend(self):
647        """
648        Remove Legend
649        """
650        #for ax in self.axes:
651        self.remove_legend(self.subplot)
652                     
653    def onMouseMotion(self, event):
654        """
655        Disable dragging 2D image
656        """
657   
658    def onWheel(self, event):
659        """
660        """
661     
662    def onLeftDown(self, event):
663        """
664        Disables LeftDown
665        """
666   
667    def onPick(self, event):
668        """
669        Remove Legend
670        """
671        for ax in self.axes:
672            self.remove_legend(ax)
673                       
674   
675    def draw(self):
676        """
677        Draw
678        """
679        if self.dimension == 3:
680            pass
681        else:
682            self.subplot.figure.canvas.draw_idle() 
683       
684    def onContextMenu(self, event):
685        """
686        Default context menu for a plot panel
687        """
688               
689class DataOperatorWindow(wx.Frame):
690    def __init__(self, parent, *args, **kwds):
691        kwds["size"] = (PANEL_WIDTH, PANEL_HEIGTH)
692        wx.Frame.__init__(self, parent, *args, **kwds)
693        self.parent = parent
694        self.panel = DataOperPanel(parent=self)
695        wx.EVT_CLOSE(self, self.OnClose)
696        self.CenterOnParent()
697        self.Show()
698   
699    def OnClose(self, event=None): 
700        """
701        On close event
702        """
703        self.Show(False)
704
705       
706if __name__ == "__main__":
707   
708    app  = wx.App()
709    window = DataEditorWindow(parent=None, data=[], title="Data Editor")
710    app.MainLoop()
711 
Note: See TracBrowser for help on using the repository browser.