Changeset b0eee0f0 in sasview
- Timestamp:
- May 18, 2009 6:12:00 PM (16 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:
- 25ccf33
- Parents:
- 0aeabc6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/gui_manager.py
rb8d7491 rb0eee0f0 20 20 import wx.aui 21 21 import os, sys 22 import xml 23 from xml import xpath 22 24 try: 23 25 # Try to find a local config … … 227 229 # Check for update 228 230 self._check_update(None) 229 231 ## maximum number of opened files' paths to store 232 self.n_maxfileopen = 2 233 ## number of file open 234 self.n_fileOpen=0 235 ## list of path of open files 236 self.filePathList=[] 237 ## list of open file with name form menu 238 #self._saveOpenData() 230 239 # Register the close event so it calls our own method 231 240 wx.EVT_CLOSE(self, self._onClose) … … 471 480 472 481 # File menu 473 filemenu = wx.Menu()482 self.filemenu = wx.Menu() 474 483 475 484 id = wx.NewId() 476 filemenu.Append(id, '&Open', 'Open a file')485 self.filemenu.Append(id, '&Open', 'Open a file') 477 486 wx.EVT_MENU(self, id, self._on_open) 478 487 #self.filemenu.AppendSeparator() 488 479 489 id = wx.NewId() 480 filemenu.Append(id,'&Quit', 'Exit')490 self.filemenu.Append(id,'&Quit', 'Exit') 481 491 wx.EVT_MENU(self, id, self.Close) 482 492 483 493 # Add sub menus 484 menubar.Append( filemenu, '&File')494 menubar.Append(self.filemenu, '&File') 485 495 486 496 # Plot menu … … 621 631 622 632 def _onClose(self, event): 633 """ 634 Store info to retrieve in xml before closing the application 635 """ 636 try: 637 doc = xml.dom.minidom.Document() 638 main_node = doc.createElement("file Path") 639 640 doc.appendChild(main_node) 641 642 for item in self.filePathList: 643 id, menuitem_name , path, title = item 644 pt1 = doc.createElement("File") 645 pt1.setAttribute("name", menuitem_name) 646 pt2 = doc.createElement("path") 647 pt2.appendChild(doc.createTextNode(str(path))) 648 pt1.appendChild(pt2) 649 pt3 = doc.createElement("title") 650 pt3.appendChild(doc.createTextNode(str(title))) 651 pt1.appendChild(pt3) 652 653 main_node.appendChild(pt1) 654 655 656 fd = open("fileOpened.xml",'w') 657 fd.write(doc.toprettyxml()) 658 fd.close() 659 except: 660 pass 661 623 662 import sys 624 663 wx.Exit() 625 664 sys.exit() 665 626 666 627 667 def Close(self, event=None): … … 679 719 dialog.ShowModal() 680 720 721 722 def _saveOpenData(self): 723 """ 724 Savename and path of n opened data into as xml file 725 """ 726 try: 727 fd = open("fileOpened.xml",'r') 728 from xml.dom.minidom import parse 729 dom = parse(fd) 730 ## Check the format version number 731 nodes = xpath.Evaluate('file Path\File', dom) 732 print "node",nodes 733 if nodes[0].hasAttributes(): 734 print "--->" 735 fd.close() 736 except: 737 raise 738 739 740 741 def _onreloaFile(self, event): 742 """ 743 load a data previously opened 744 """ 745 from data_loader import plot_data 746 for item in self.filePathList: 747 id, menuitem_name , path, title = item 748 if id == event.GetId(): 749 if path and os.path.isfile(path): 750 plot_data(self, path) 751 break 752 753 681 754 def set_manager(self, manager): 682 755 """ … … 731 804 try: 732 805 self._default_save_location = os.path.dirname(path) 806 807 self.n_fileOpen += 1 808 if self.n_fileOpen==1: 809 pos= self.filemenu.GetMenuItemCount()-1 810 #self.filemenu.InsertSeparator(pos ) 811 812 id = wx.NewId() 813 filename= os.path.basename(path) 814 dir= os.path.split(self._default_save_location)[1] 815 title= str(os.path.join(dir,filename )) 816 menuitem_name = str(self.n_fileOpen)+". "+ title 817 position= self.filemenu.GetMenuItemCount()-2 818 #self.filemenu.Insert(id=id, pos= position,text=menuitem_name,help=str(path) ) 819 #self.filePathList.append(( id, menuitem_name, path, title)) 820 #wx.EVT_MENU(self, id, self._onreloaFile) 821 822 ## construct menu item for open file 823 if self.n_fileOpen == self.n_maxfileopen +1: 824 ## reach the maximun number of path to store 825 self.n_fileOpen = 0 826 id, menuitem_name , path, title = self.filePathList[0] 827 self.filemenu.Delete(id) 828 self.filePathList.pop(0) 829 for item in self.filePathList: 830 id, menuitem_name , path, title = item 831 self.n_fileOpen += 1 832 label = str(self.n_fileOpen)+". "+ title 833 #self.filemenu.FindItemById(id).SetItemLabel(label) 834 835 733 836 except: 734 pass 837 raise 838 #pass 735 839 return path 736 840
Note: See TracChangeset
for help on using the changeset viewer.