Changeset 1729


Ignore:
Timestamp:
Mar 17, 2015 1:34:37 PM (7 years ago)
Author:
toby
Message:

switch default download dir; remove old tutorial help item; pretty-up help dialog; fix bug on directory change

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r1719 r1729  
    20332033            self._init_Macro()
    20342034        HelpMenu=G2G.MyHelp(self,helpType='Data tree',
    2035             morehelpitems=[('&Old Tutorials','OldTutorials'), # this will eventually go away
    2036                            ('&Download Tutorial','Tutorials'),
     2035            morehelpitems=[#('&Old Tutorials','OldTutorials'), # this will eventually go away
     2036                           ('&Tutorials','Tutorials'),
    20372037                           ])
    20382038        menubar.Append(menu=HelpMenu,title='&Help')
  • trunk/GSASIIctrls.py

    r1722 r1729  
    14851485            print 'Error: help lookup failed!',event.GetEventObject()
    14861486            print 'id=',event.GetId()
    1487         elif helpType == 'OldTutorials': # this will go away
    1488             #self.frame.Tutorials = True
    1489             ShowHelp(helpType,self.frame)
     1487        #elif helpType == 'OldTutorials': # this will go away
     1488            #ShowHelp(helpType,self.frame)
    14901489        elif helpType == 'Tutorials':
    14911490            dlg = OpenTutorial(self.frame)
    14921491            dlg.ShowModal()
    1493             #if dlg.ShowModal() == wx.ID_OK:
    1494                 #self.frame.Tutorials = True
    14951492            dlg.Destroy()
    14961493            return
     
    17281725        self.dlg.SetSizer(mainSizer)
    17291726        mainSizer.Fit(self.dlg)
     1727        self.dlg.CenterOnParent()
    17301728        self.dlg.ShowModal()
    17311729        self.dlg.Destroy()
     
    20202018    tutorialPath = GSASIIpath.GetConfigValue('Tutorial_location')
    20212019else:
    2022     tutorialPath = GSASIIpath.path2GSAS2
     2020    # pick a default directory in a logical place
     2021    if sys.platform.lower().startswith('win') and os.path.exists(os.path.abspath(os.path.expanduser('~/My Documents'))):
     2022        tutorialPath = os.path.abspath(os.path.expanduser('~/My Documents/G2tutorials'))
     2023    else:
     2024        tutorialPath = os.path.abspath(os.path.expanduser('~/G2tutorials'))
    20232025
    20242026class OpenTutorial(wx.Dialog):
     
    20372039        pnl = wx.Panel(self)
    20382040        sizer = wx.BoxSizer(wx.VERTICAL)
     2041        sizer1 = wx.BoxSizer(wx.HORIZONTAL)       
    20392042        label = wx.StaticText(
    20402043            pnl,  wx.ID_ANY,
    20412044            'Select the tutorial to be run and the mode of access'
    20422045            )
    2043         sizer.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
    20442046        msg = '''To save download time for GSAS-II tutorials and their
    20452047        sample data files are being moved out of the standard
     
    20612063        '''
    20622064        hlp = HelpButton(pnl,msg)
    2063         sizer.Add(hlp,0,wx.ALIGN_RIGHT|wx.ALL)
     2065        sizer1.Add((-1,-1),1, wx.EXPAND, 0)
     2066        sizer1.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 0)
     2067        sizer1.Add((-1,-1),1, wx.EXPAND, 0)
     2068        sizer1.Add(hlp,0,wx.ALIGN_RIGHT|wx.ALL)
     2069        sizer.Add(sizer1,0,wx.EXPAND|wx.ALL,0)
     2070        sizer.Add((10,10))
    20642071        #======================================================================
    20652072        # # This is needed only until we get all the tutorials items moved
     
    20812088        self.mode.Bind(wx.EVT_RADIOBOX, self.OnModeSelect)
    20822089        sizer.Add(self.mode,0,WACV)
     2090        sizer.Add((10,10))
     2091        label = wx.StaticText(pnl,  wx.ID_ANY,'Click on tutorial to be opened:')
     2092        sizer.Add(label, 0, wx.ALIGN_LEFT|wx.ALL, 2)
     2093        self.listbox = wx.ListBox(pnl, wx.ID_ANY, size=(450, 100), style=wx.LB_SINGLE)
     2094        self.listbox.Bind(wx.EVT_LISTBOX, self.OnTutorialSelected)
     2095        sizer.Add(self.listbox,1,WACV|wx.EXPAND|wx.ALL,1)
     2096        sizer.Add((10,10))
    20832097        sizer1 = wx.BoxSizer(wx.HORIZONTAL)
    20842098        btn = wx.Button(pnl, wx.ID_ANY, "Set download location")
     
    20922106            'Tutorials and Exercise files will be downloaded to:'
    20932107            )
    2094         sizer.Add(label, 0, wx.ALIGN_LEFT|wx.ALL, 5)
     2108        sizer.Add(label, 0, wx.ALIGN_LEFT|wx.ALL, 1)
    20952109        self.TutorialLabel = wx.StaticText(pnl,wx.ID_ANY,'')
    20962110        sizer.Add(self.TutorialLabel, 0, wx.ALIGN_LEFT|wx.EXPAND, 5)
    20972111        self.ExerciseLabel = wx.StaticText(pnl,wx.ID_ANY,'')
     2112        sizer.Add(self.ExerciseLabel, 0, wx.ALIGN_LEFT|wx.EXPAND, 5)
    20982113        self.ShowTutorialPath()
    2099         sizer.Add(self.ExerciseLabel, 0, wx.ALIGN_LEFT|wx.EXPAND, 5)
    2100         self.listbox = wx.ListBox(pnl, wx.ID_ANY, size=(450, 100), style=wx.LB_SINGLE)
    2101         self.listbox.Bind(wx.EVT_LISTBOX, self.OnTutorialSelected)
    21022114        self.OnModeSelect(None)
    2103         #self.FillListBox()
    2104         sizer.Add(self.listbox,1,WACV|wx.EXPAND|wx.ALL,1)
    21052115       
    21062116        btnsizer = wx.StdDialogButtonSizer()
     
    21172127    #     '''
    21182128    #     self.EndModal(wx.ID_OK)
    2119     #     self.frame.Tutorials = True
    21202129    #     ShowHelp('Tutorials',self.frame)
    21212130    def OnModeSelect(self,event):
     
    21612170            self.LoadExercise(exedir,tutorialPath,G2BaseURL)
    21622171            URL = os.path.join(tutorialPath,'help',tutdir,htmlname)
     2172            self.frame.ImportDir = os.path.join(tutorialPath,'Exercises',exedir)
    21632173            ShowWebPage(URL,self.frame)
    2164             self.frame.ImportDir = os.path.join(tutorialPath,'Exercises',exedir)
    21652174        elif self.BrowseMode == 1:
    21662175            # xfer data locally, open web page remotely
    21672176            self.LoadExercise(exedir,tutorialPath,G2BaseURL)
    21682177            URL = os.path.join(G2BaseURL,'Tutorials',tutdir,htmlname)
     2178            self.frame.ImportDir = os.path.join(tutorialPath,'Exercises',exedir)
    21692179            ShowWebPage(URL,self.frame)
    2170             self.frame.ImportDir = os.path.join(tutorialPath,'Exercises',exedir)
    21712180        elif self.BrowseMode == 2:
    21722181            # open web page remotely, don't worry about data
    21732182            URL = os.path.join(G2BaseURL,'Tutorials',tutdir,htmlname)
    21742183            ShowWebPage(URL,self.frame)
    2175             self.frame.ImportDir = os.path.join(tutorialPath,'Exercises',exedir)
    21762184        elif self.BrowseMode == 3:
    21772185            # open web page that has already been transferred
    21782186            URL = os.path.join(tutorialPath,'help',tutdir,htmlname)
     2187            self.frame.ImportDir = os.path.join(tutorialPath,'Exercises',exedir)
    21792188            ShowWebPage(URL,self.frame)
    21802189        else:
     
    21942203        throws an exception if there is a problem.
    21952204        '''
     2205        wx.BeginBusyCursor()
     2206        wx.Yield()
    21962207        if os.path.exists(fullpath):
    21972208            if os.path.exists(os.path.join(fullpath,"help")):
    21982209                if not GSASIIpath.svnGetRev(os.path.join(fullpath,"help")):
    21992210                    print("Problem with "+fullpath+" dir help exists but is not in SVN")
     2211                    wx.EndBusyCursor()
    22002212                    raise Exception
    22012213            if os.path.exists(os.path.join(fullpath,"Exercises")):
    22022214                if not GSASIIpath.svnGetRev(os.path.join(fullpath,"Exercises")):
    22032215                    print("Problem with "+fullpath+" dir Exercises exists but is not in SVN")
     2216                    wx.EndBusyCursor()
    22042217                    raise Exception
    22052218            if (os.path.exists(os.path.join(fullpath,"help")) and
    22062219                    os.path.exists(os.path.join(fullpath,"Exercises"))):
     2220                if self.BrowseMode != 3:
     2221                    print('Checking for directory updates')
     2222                    GSASIIpath.svnUpdateDir(os.path.join(fullpath,"help"))
     2223                    GSASIIpath.svnUpdateDir(os.path.join(fullpath,"Exercises"))
     2224                wx.EndBusyCursor()
    22072225                return True # both good
    22082226            elif (os.path.exists(os.path.join(fullpath,"help")) or
    22092227                    os.path.exists(os.path.join(fullpath,"Exercises"))):
    22102228                print("Problem: dir "+fullpath+" exists has either help or Exercises, not both")
     2229                wx.EndBusyCursor()
    22112230                raise Exception
    2212         wx.BeginBusyCursor()
    22132231        if not GSASIIpath.svnInstallDir(baseURL+"/MT",fullpath):
    22142232            wx.EndBusyCursor()
     
    22372255        '''
    22382256        global tutorialPath
    2239         localpath = os.path.abspath(os.path.expanduser('~/G2tutorials'))
    22402257        dlg = wx.DirDialog(self, "Choose a directory for downloads:",
    2241                            defaultPath=localpath)#,style=wx.DD_DEFAULT_STYLE)
     2258                           defaultPath=tutorialPath)#,style=wx.DD_DEFAULT_STYLE)
    22422259                           #)
    2243         if dlg.ShowModal() == wx.ID_OK:
     2260        try:
     2261            if dlg.ShowModal() != wx.ID_OK:
     2262                return
    22442263            pth = dlg.GetPath()
    2245         else:
    2246             if GSASIIpath.GetConfigValue('Tutorial_location'):
    2247                 pth = GSASIIpath.GetConfigValue('Tutorial_location')
    2248             else:
    2249                 pth = GSASIIpath.path2GSAS2
     2264        finally:
     2265            dlg.Destroy()
     2266
    22502267        if not os.path.exists(pth):
    22512268            try:
     
    22622279        except:
    22632280            G2MessageBox(self.frame,
    2264             '''The selected directory is not valid.
     2281            '''Error downloading to the selected directory
     2282
     2283            Are you connected to the internet? If not, you can
     2284            only view previously downloaded tutorials (select
     2285            "open from local...")
    22652286           
    22662287            You must use a directory that you have write access
    22672288            to. You can reuse a directory previously used for
    22682289            downloads, but the help and Tutorials subdirectories
    2269              must be created by this routine.
     2290            must have been created by this routine.
    22702291            ''')
    22712292        self.dataLoc.SetLabel(tutorialPath)
    22722293        self.ShowTutorialPath()
     2294        self.OnModeSelect(None)
    22732295   
    22742296if __name__ == '__main__':
  • trunk/GSASIIpath.py

    r1701 r1729  
    378378           '--accept','theirs-conflict','--force']
    379379    if svnVersionNumber() > 1.6: cmd += ['--ignore-ancestry']
    380     print("Loading files from "+URL)
     380    print("Loading files from "+URL+'\n  to '+fpath)
    381381    s = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
    382382    out,err = s.communicate()
  • trunk/config_example.py

    r1719 r1729  
    3939Tutorial_location = None
    4040'''Change this to place tutorials by in a different spot. If None, this defaults to
    41 the location where GSAS-II is loaded GSASIIpath.path2GSAS2. For installations where
    42 G2 is installed by an administrator, it is a good idea to use something like this::
     41~/My Documents/G2tutorials (on windows) or ~/G2tutorials. If you want to use a different
     42location (such as to use the GSASII installation directory), this can be set here.
     43As an example, to always use ~/G2tutorials do this::
    4344
    4445    import os.path
    4546    Tutorial_location = os.path.join(os.path.expanduser('~'),'G2tutorials')
    4647
    47 This will allow users to download tutorial files into their own file space.
     48To install into the location where GSAS-II is installed, use this::
     49
     50    import GSASIIpath
     51    Tutorial_location = GSASIIpath.path2GSAS2
     52
    4853'''
    4954
Note: See TracChangeset for help on using the changeset viewer.