Ignore:
Timestamp:
Aug 10, 2019 10:22:02 AM (4 years ago)
Author:
toby
Message:

Add menu accelerator keys & recently used menu

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIdataGUI.py

    r4075 r4085  
    464464   
    465465    def _Add_FileMenuItems(self, parent):
    466         item = parent.Append(wx.ID_ANY,'&Open project...','Open a GSAS-II project file (*.gpx)')           
     466        item = parent.Append(wx.ID_ANY,'&Open project...\tCtrl+O','Open a GSAS-II project file (*.gpx)')           
    467467        self.Bind(wx.EVT_MENU, self.OnFileOpen, id=item.GetId())
    468         item = parent.Append(wx.ID_ANY,'&Save project','Save project under current name')
     468        item = parent.Append(wx.ID_ANY,'Reopen recent...\tCtrl+R','Reopen a previously used GSAS-II project file (*.gpx)')
     469        self.Bind(wx.EVT_MENU, self.OnFileReopen, id=item.GetId())
     470        item = parent.Append(wx.ID_ANY,'&Save project\tCtrl+S','Save project under current name')
    469471        self.Bind(wx.EVT_MENU, self.OnFileSave, id=item.GetId())
    470472        item = parent.Append(wx.ID_ANY,'Save project as...','Save current project to new file')
     
    27642766        if addhelp:
    27652767            HelpMenu=G2G.MyHelp(self,includeTree=True,
    2766                 morehelpitems=[('&Tutorials','Tutorials'),])
     2768                morehelpitems=[('&Tutorials\tCtrl+T','Tutorials'),])
    27672769            menubar.Append(menu=HelpMenu,title='&Help')
    27682770           
     
    38073809                dlg.Destroy()
    38083810
     3811    def OnFileReopen(self, event):
     3812        files = GSASIIpath.GetConfigValue('previous_GPX_files')
     3813        if not files:
     3814            print('no previous projects saved')
     3815            return
     3816        sellist = []
     3817        for f in files:
     3818            dirname,filroot = os.path.split(f)
     3819            if os.path.exists(f):
     3820                sellist.append("{} from {}".format(filroot,dirname))
     3821            else:
     3822                sellist.append("not found: {}".format(f))
     3823       
     3824        dlg = G2G.G2SingleChoiceDialog(self,
     3825                                           'Select previous project to open',
     3826                                           'Select project',sellist)
     3827        if dlg.ShowModal() == wx.ID_OK:
     3828            sel = dlg.GetSelection()
     3829            dlg.Destroy()
     3830        else:
     3831            dlg.Destroy()
     3832            return
     3833        f = files[sel]
     3834        if os.path.exists(f):
     3835            self.OnFileOpen(event, filename=f)
     3836        else:
     3837            print('file not found',f)       
     3838       
    38093839    def OnFileOpen(self, event, filename=None):
    38103840        '''Gets a GSAS-II .gpx project file in response to the
     
    39103940        if self.dirname: os.chdir(self.dirname)           # to get Mac/Linux to change directory!
    39113941        pth = os.path.split(os.path.abspath(self.GSASprojectfile))[0]
    3912         if GSASIIpath.GetConfigValue('Save_paths'): G2G.SaveGPXdirectory(pth)
     3942        if GSASIIpath.GetConfigValue('Save_paths'):
     3943            G2G.SaveGPXdirectory(pth,write=False)
     3944        config = G2G.GetConfigValsDocs()
     3945        GSASIIpath.addPrevGPX(self.GSASprojectfile,config)
     3946        G2G.SaveConfigVars(config)
    39133947        self.LastGPXdir = pth
    39143948
Note: See TracChangeset for help on using the changeset viewer.