Ignore:
Timestamp:
Sep 12, 2011 10:18:19 AM (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:
dc79cfc
Parents:
caf3a08f
Message:

modify batch dialog to frame window

File:
1 edited

Legend:

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

    rcaf3a08f r83eb1b52  
    622622       
    623623       
    624 class BatchOutputDialog(wx.Dialog): 
     624class BatchOutputFrame(wx.Frame): 
    625625    """ 
    626626    Allow to select where the result of batch will be displayed or stored 
    627627    """ 
    628     def __init__(self, parent=None, data=None, file_name="", 
     628    def __init__(self, parent, data=None, file_name="", 
    629629                 details="", *args, **kwds): 
    630630        """ 
     
    634634        """ 
    635635        #kwds['style'] = wx.CAPTION|wx.SYSTEM_MENU  
    636         wx.Dialog.__init__(self, parent, *args, **kwds) 
     636        wx.Frame.__init__(self, parent, *args, **kwds) 
    637637        self.parent = parent 
     638        self.panel = wx.Panel(self) 
    638639        self.file_name = file_name 
    639640        self.details = details 
     
    651652        """ 
    652653        vbox = wx.BoxSizer(wx.VERTICAL) 
    653         box_description= wx.StaticBox(self, -1,str("Batch Outputs")) 
     654        box_description = wx.StaticBox(self.panel, -1, str("Batch Outputs")) 
    654655        hint_sizer = wx.StaticBoxSizer(box_description, wx.VERTICAL) 
    655         selection_sizer = wx.GridBagSizer(5,5) 
     656        selection_sizer = wx.GridBagSizer(5, 5) 
    656657        button_sizer = wx.BoxSizer(wx.HORIZONTAL) 
    657658        text = "Open with %s" % self.parent.application_name  
    658         self.local_app_selected = wx.RadioButton(self, -1, text, 
     659        self.local_app_selected = wx.RadioButton(self.panel, -1, text, 
    659660                                                style=wx.RB_GROUP) 
    660661        self.Bind(wx.EVT_RADIOBUTTON, self.onselect, 
    661662                    id=self.local_app_selected.GetId()) 
    662663        text = "Open with Excel" 
    663         self.external_app_selected  = wx.RadioButton(self, -1, text) 
     664        self.external_app_selected  = wx.RadioButton(self.panel, -1, text) 
    664665        self.Bind(wx.EVT_RADIOBUTTON, self.onselect, 
    665666                    id=self.external_app_selected.GetId()) 
    666667        text = "Save to File" 
    667         self.save_to_file = wx.CheckBox(self, -1, text) 
     668        self.save_to_file = wx.CheckBox(self.panel, -1, text) 
    668669        self.Bind(wx.EVT_CHECKBOX, self.onselect, 
    669670                    id=self.save_to_file.GetId()) 
     
    671672        self.external_app_selected.SetValue(False) 
    672673        self.save_to_file.SetValue(False) 
    673         button_close = wx.Button(self, wx.ID_OK, "Close") 
    674         button_OK = wx.Button(self, wx.ID_CANCEL, "Apply") 
    675         button_OK.SetFocus() 
     674        button_close = wx.Button(self.panel, -1, "Close") 
     675        button_close.Bind(wx.EVT_BUTTON, id=button_close.GetId(), 
     676                           handler=self.on_close) 
     677        button_apply = wx.Button(self.panel, -1, "Apply") 
     678        button_apply.Bind(wx.EVT_BUTTON, id=button_apply.GetId(), 
     679                        handler=self.on_apply) 
     680        button_apply.SetFocus() 
    676681        hint = "" 
    677         hint_sizer.Add(wx.StaticText(self, -1, hint)) 
     682        hint_sizer.Add(wx.StaticText(self.panel, -1, hint)) 
    678683        hint_sizer.Add(selection_sizer) 
    679684        #draw area containing radio buttons 
     
    693698        button_sizer.Add(button_close, 0, 
    694699                        wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    695         button_sizer.Add(button_OK, 0, 
     700        button_sizer.Add(button_apply, 0, 
    696701                                wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) 
    697702        vbox.Add(hint_sizer,  0, wx.EXPAND|wx.ALL, 10) 
    698         vbox.Add(wx.StaticLine(self, -1),  0, wx.EXPAND, 0) 
     703        vbox.Add(wx.StaticLine(self.panel, -1),  0, wx.EXPAND, 0) 
    699704        vbox.Add(button_sizer, 0 , wx.TOP|wx.BOTTOM, 10) 
    700705        self.SetSizer(vbox) 
     706         
     707    def on_apply(self, event): 
     708        """ 
     709        Get the user selection and display output to the selected application 
     710        """ 
     711        if self.flag == 1: 
     712            self.parent.open_with_localapp(self.data) 
     713        elif self.flag == 2: 
     714            self.parent.open_with_externalapp(data=self.data,  
     715                                           file_name=self.file_name, 
     716                                           details=self.details) 
     717    def on_close(self, event): 
     718        """ 
     719        close the Window 
     720        """ 
     721        self.Close() 
    701722         
    702723    def onselect(self, event=None): 
     
    711732            location = os.getcwd() 
    712733            if self.parent is not None:  
    713                 location = self.parent._default_save_location 
     734                location = os.path.dirname(self.file_name) 
    714735                dlg = wx.FileDialog(self, "Save Project file", 
    715736                            location, self.file_name, ext, wx.SAVE) 
     
    717738                if dlg.ShowModal() == wx.ID_OK: 
    718739                    path = dlg.GetPath() 
    719                     if self.parent is not None: 
    720                         self.parent._default_save_location = os.path.dirname(path) 
    721740                dlg.Destroy() 
    722741                if path != None: 
    723742                    if self.parent is not None and  self.data is not None: 
    724                         self.parent.write_batch_output(data=self.data,  
     743                        self.parent.write_batch_tofile(data=self.data,  
    725744                                               file_name=path, 
    726745                                               details=self.details) 
    727          
    728746        if self.local_app_selected.GetValue(): 
    729747            self.flag = 1 
     
    731749            self.flag = 2 
    732750        return self.flag 
    733      
    734     def save_file(self): 
    735         """ 
    736         Save inot file 
    737         """ 
    738          
    739751     
    740752   
Note: See TracChangeset for help on using the changeset viewer.