Ignore:
Timestamp:
Sep 9, 2011 3:57:52 PM (13 years ago)
Author:
Gervaise Alina <gervyh@…>
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:
3bc6090
Parents:
7f76f89
Message:

working on batch gui

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansguiframe/src/sans/guiframe/data_processor.py

    r10675c3 r73197d0  
    2121FUNC_DICT = {"sqrt": "math.sqrt", 
    2222             "pow": "math.sqrt"} 
     23 
     24 
     25 
    2326def parse_string(sentence, list): 
    2427    """ 
     
    618621       
    619622       
     623class BatchOutputDialog(wx.Dialog): 
     624    """ 
     625    Allow to select where the result of batch will be displayed or stored 
     626    """ 
     627    def __init__(self, parent=None, data=None, *args, **kwds): 
     628        """ 
     629        :param parent: Window instantiating this dialog 
     630        :param result: result to display in a grid or export to an external  
     631                application. 
     632        """ 
     633        kwds['style'] = wx.CAPTION|wx.SYSTEM_MENU  
     634        wx.Dialog.__init__(self, parent, *args, **kwds) 
     635        self.parent = parent 
     636        self.data = data 
     637        self.flag = 1 
     638        self.SetSize((300, 200)) 
     639        self.local_app_selected = None 
     640        self.external_app_selected = None 
     641        self.save_to_file = None 
     642        self._do_layout() 
     643 
     644    def _do_layout(self): 
     645        """ 
     646        Draw the content of the current dialog window 
     647        """ 
     648        vbox = wx.BoxSizer(wx.VERTICAL) 
     649        box_description= wx.StaticBox(self, -1,str("Batch Outputs")) 
     650        hint_sizer = wx.StaticBoxSizer(box_description, wx.VERTICAL) 
     651        selection_sizer = wx.GridBagSizer(5,5) 
     652        button_sizer = wx.BoxSizer(wx.HORIZONTAL) 
     653        text = "Open with SansView" 
     654        self.local_app_selected = wx.RadioButton(self, -1, text, 
     655                                                style=wx.RB_GROUP) 
     656        self.Bind(wx.EVT_RADIOBUTTON, self.onselect, 
     657                    id=self.local_app_selected.GetId()) 
     658        text = "Open with Excel" 
     659        self.external_app_selected  = wx.RadioButton(self, -1, text) 
     660        self.Bind(wx.EVT_RADIOBUTTON, self.onselect, 
     661                    id=self.external_app_selected.GetId()) 
     662        text = "Save to file" 
     663        self.save_to_file = wx.CheckBox(self, -1, text) 
     664        self.Bind(wx.EVT_CHECKBOX, self.onselect, 
     665                    id=self.save_to_file.GetId()) 
     666        self.local_app_selected.SetValue(True) 
     667        self.external_app_selected.SetValue(False) 
     668        self.save_to_file.SetValue(False) 
     669   
     670        button_OK = wx.Button(self, wx.ID_OK, "Ok") 
     671        button_OK.SetFocus() 
     672        hint = "" 
     673        hint_sizer.Add(wx.StaticText(self, -1, hint)) 
     674        hint_sizer.Add(selection_sizer) 
     675        #draw area containing radio buttons 
     676        ix = 0 
     677        iy = 0 
     678        selection_sizer.Add(self.local_app_selected, (iy, ix), 
     679                           (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     680        iy += 1 
     681        selection_sizer.Add(self.external_app_selected, (iy, ix), 
     682                           (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     683        iy += 1 
     684        selection_sizer.Add(self.save_to_file, (iy, ix), 
     685                           (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     686        #contruction the sizer contaning button 
     687        button_sizer.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     688        button_sizer.Add(button_OK, 0, 
     689                                wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) 
     690        vbox.Add(hint_sizer,  0, wx.EXPAND|wx.ALL, 10) 
     691        vbox.Add(wx.StaticLine(self, -1),  0, wx.EXPAND, 0) 
     692        vbox.Add(button_sizer, 0 , wx.TOP|wx.BOTTOM, 10) 
     693        self.SetSizer(vbox) 
     694         
     695    def onselect(self, event=None): 
     696        """ 
     697        Receive event and display data into third party application 
     698        or save data to file. 
     699         
     700        """ 
     701        if self.save_to_file.GetValue(): 
     702            self.flag = 3 
     703            if self.parent is not None and  self.data is not None: 
     704                self.parent.save_batch_into_file(self.data) 
     705        elif self.local_app_selected.GetValue(): 
     706            self.flag = 1 
     707        else: 
     708            self.flag = 2 
     709        return self.flag 
     710     
     711   
     712         
    620713if __name__ == "__main__": 
    621714    app = wx.App() 
Note: See TracChangeset for help on using the changeset viewer.