Changeset 83eb1b52 in sasview for sansguiframe
- Timestamp:
- Sep 12, 2011 10:18:19 AM (13 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:
- dc79cfc
- Parents:
- caf3a08f
- Location:
- sansguiframe/src/sans/guiframe
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sansguiframe/src/sans/guiframe/data_processor.py
rcaf3a08f r83eb1b52 622 622 623 623 624 class BatchOutput Dialog(wx.Dialog):624 class BatchOutputFrame(wx.Frame): 625 625 """ 626 626 Allow to select where the result of batch will be displayed or stored 627 627 """ 628 def __init__(self, parent =None, data=None, file_name="",628 def __init__(self, parent, data=None, file_name="", 629 629 details="", *args, **kwds): 630 630 """ … … 634 634 """ 635 635 #kwds['style'] = wx.CAPTION|wx.SYSTEM_MENU 636 wx. Dialog.__init__(self, parent, *args, **kwds)636 wx.Frame.__init__(self, parent, *args, **kwds) 637 637 self.parent = parent 638 self.panel = wx.Panel(self) 638 639 self.file_name = file_name 639 640 self.details = details … … 651 652 """ 652 653 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")) 654 655 hint_sizer = wx.StaticBoxSizer(box_description, wx.VERTICAL) 655 selection_sizer = wx.GridBagSizer(5, 5)656 selection_sizer = wx.GridBagSizer(5, 5) 656 657 button_sizer = wx.BoxSizer(wx.HORIZONTAL) 657 658 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, 659 660 style=wx.RB_GROUP) 660 661 self.Bind(wx.EVT_RADIOBUTTON, self.onselect, 661 662 id=self.local_app_selected.GetId()) 662 663 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) 664 665 self.Bind(wx.EVT_RADIOBUTTON, self.onselect, 665 666 id=self.external_app_selected.GetId()) 666 667 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) 668 669 self.Bind(wx.EVT_CHECKBOX, self.onselect, 669 670 id=self.save_to_file.GetId()) … … 671 672 self.external_app_selected.SetValue(False) 672 673 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() 676 681 hint = "" 677 hint_sizer.Add(wx.StaticText(self , -1, hint))682 hint_sizer.Add(wx.StaticText(self.panel, -1, hint)) 678 683 hint_sizer.Add(selection_sizer) 679 684 #draw area containing radio buttons … … 693 698 button_sizer.Add(button_close, 0, 694 699 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 695 button_sizer.Add(button_ OK, 0,700 button_sizer.Add(button_apply, 0, 696 701 wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) 697 702 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) 699 704 vbox.Add(button_sizer, 0 , wx.TOP|wx.BOTTOM, 10) 700 705 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() 701 722 702 723 def onselect(self, event=None): … … 711 732 location = os.getcwd() 712 733 if self.parent is not None: 713 location = self.parent._default_save_location734 location = os.path.dirname(self.file_name) 714 735 dlg = wx.FileDialog(self, "Save Project file", 715 736 location, self.file_name, ext, wx.SAVE) … … 717 738 if dlg.ShowModal() == wx.ID_OK: 718 739 path = dlg.GetPath() 719 if self.parent is not None:720 self.parent._default_save_location = os.path.dirname(path)721 740 dlg.Destroy() 722 741 if path != None: 723 742 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, 725 744 file_name=path, 726 745 details=self.details) 727 728 746 if self.local_app_selected.GetValue(): 729 747 self.flag = 1 … … 731 749 self.flag = 2 732 750 return self.flag 733 734 def save_file(self):735 """736 Save inot file737 """738 739 751 740 752 -
sansguiframe/src/sans/guiframe/gui_manager.py
rcaf3a08f r83eb1b52 38 38 from sans.guiframe.gui_toolbar import GUIToolBar 39 39 from sans.guiframe.data_processor import GridFrame 40 from sans.guiframe.data_processor import BatchOutput Dialog40 from sans.guiframe.data_processor import BatchOutputFrame 41 41 from sans.guiframe.events import EVT_NEW_BATCH 42 42 from sans.dataloader.loader import Loader … … 299 299 ext = ".csv" 300 300 file_name = "Batch_" + str(plugin_name)+ "_" + time_str + ext 301 file_name = self._default_save_location + str(file_name) 301 302 #Need to save configuration for later 302 dlg = BatchOutputDialog(parent=self, data=data,303 frame = BatchOutputFrame(parent=self, data=data, 303 304 file_name=file_name, 304 305 details=details) 305 flag = None 306 if dlg.ShowModal() == wx.ID_CANCEL: 307 flag = dlg.flag 308 dlg.Show(True) 309 else: 310 dlg.Destroy() 311 if flag == 1: 312 self.batch_frame.set_data(data) 313 self.batch_frame.Show(True) 314 elif flag == 2: 315 file_name = self._default_save_location + str(file_name) 316 if not os.path.exists(file_name): 317 self.write_batch_output(data=data, file_name=file_name, 318 details=details) 319 self.deplay_in_external_app(data=data, file_name=file_name, 320 plugin_name=plugin_name) 321 322 def write_batch_output(self, data, file_name, details=""): 306 frame.Show(True) 307 308 def open_with_localapp(self, data): 309 """ 310 Display value of data into the application grid 311 :param data: dictionary of string and list of items 312 """ 313 self.batch_frame.set_data(data) 314 self.batch_frame.Show(True) 315 316 def write_batch_tofile(self, data, file_name, details=""): 323 317 """ 324 318 Helper to write result from batch into cvs file 325 319 """ 326 320 self._default_save_location = os.path.dirname(file_name) 321 file_name = os.path.basename(file_name) 327 322 if data is None or file_name is None or file_name.strip() == "": 328 323 return … … 357 352 fd.close() 358 353 359 def deplay_in_external_app(self, data, file_name, plugin_name):354 def open_with_externalapp(self, data, file_name, details=""): 360 355 """ 361 356 Display data in the another application , by default Excel 362 357 """ 358 if not os.path.exists(file_name): 359 self.write_batch_tofile(data=data, file_name=file_name, 360 details=details) 363 361 try: 364 362 from win32com.client import Dispatch
Note: See TracChangeset
for help on using the changeset viewer.