Changeset 1719


Ignore:
Timestamp:
Mar 16, 2015 4:20:06 PM (9 years ago)
Author:
toby
Message:

implement default starting and import directories

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r1715 r1719  
    368368            if not reader.strictExtension:
    369369                choices += "|any file (*.*)|*.*"
    370         # get the file(s)
     370        # get the file(s) (probably should remove wx.CHANGE_DIR here)
    371371        if multiple:
    372372            mode = style=wx.OPEN | wx.CHANGE_DIR | wx.MULTIPLE
    373373        else:
    374374            mode = style=wx.OPEN | wx.CHANGE_DIR
    375         dlg = wx.FileDialog(self, message="Choose "+label+" input file",
    376             defaultFile="",wildcard=choices, style=mode)
    377         if self.Tutorials:
    378             dlg.SetDirectory(os.path.join(GSASIIpath.path2GSAS2,'Exercises'))
    379             self.Tutorials = False
    380         try:
    381             if dlg.ShowModal() == wx.ID_OK:
    382                 if multiple:
    383                     filelist = dlg.GetPaths()
    384                     if len(filelist) == 0: return []
    385                 else:
    386                     filename = dlg.GetPath()
    387                     filelist = [filename,]
    388                 os.chdir(dlg.GetDirectory())           # to get Mac/Linux to change directory!
    389             else: # cancel was pressed
    390                 return []
    391         finally:
    392             dlg.Destroy()
     375        filelist = self.GetImportFile(message="Choose "+label+" input file",
     376                    defaultFile="",wildcard=choices, style=mode)
    393377        rd_list = []
    394378        filelist1 = []
     
    539523        self.Bind(wx.EVT_MENU, self.OnImportPhase, id=item.GetId())
    540524
     525    def GetImportFile(self, message, defaultDir="", defaultFile="", style=wx.OPEN,
     526                      *args, **kwargs):
     527        '''Defines a customized dialog that gets gets files from the appropriate
     528        Import directory (unless overridden with defaultDir). The default
     529        import directory is found in self.ImportDir, which will be set to
     530        the location of the (first) file entered in this dialog.
     531           
     532        :returns: a list of files or an empty list
     533        '''
     534        dlg = wx.FileDialog(self, message, defaultDir, defaultFile, *args,
     535                            style=style, **kwargs)
     536        if not defaultDir and self.ImportDir:
     537            dlg.SetDirectory(self.ImportDir)
     538        try:
     539            if dlg.ShowModal() == wx.ID_OK:
     540                if style & wx.MULTIPLE:
     541                    filelist = dlg.GetPaths()
     542                    if len(filelist) == 0: return []
     543                else:
     544                    filelist = [dlg.GetPath(),]
     545                # not sure if we want to do this (why use wx.CHANGE_DIR?)
     546                if style & wx.CHANGE_DIR: # to get Mac/Linux to change directory like windows!
     547                    os.chdir(dlg.GetDirectory())
     548                if not defaultDir and self.ImportDir: # if we are using a default and
     549                    # user moved, save the new location
     550                    self.ImportDir = os.path.split(filelist[0])[0]
     551                    #print 'default moved to',self.ImportDir               
     552            else: # cancel was pressed
     553                return []
     554        finally:
     555            dlg.Destroy()
     556        return filelist
     557           
    541558    def OnImportPhase(self,event):
    542559        '''Called in response to an Import/Phase/... menu item
     
    21342151        self.StrainKey = ''         #ditto for new strain d-zeros
    21352152        self.EnablePlot = True
    2136         self.Tutorials = False      #used for changing default directory
     2153        if GSASIIpath.GetConfigValue('Starting_directory'):
     2154            try:
     2155                os.chdir(GSASIIpath.GetConfigValue('Starting_directory'))
     2156            except:
     2157                print('Ignoring Config Starting_directory value: '+
     2158                      GSASIIpath.GetConfigValue('Starting_directory'))
    21372159        arg = sys.argv
    21382160        if len(arg) > 1 and arg[1]:
     
    21472169            except:
    21482170                print 'Error opening file',arg[1]
     2171             
     2172        self.ImportDir = os.path.normpath(os.getcwd()) # specifies a default path to be used for imports
     2173        if GSASIIpath.GetConfigValue('Import_directory'):
     2174            self.ImportDir = GSASIIpath.GetConfigValue('Import_directory')
    21492175
    21502176    def OnSize(self,event):
  • trunk/GSASIIctrls.py

    r1709 r1719  
    14861486            print 'id=',event.GetId()
    14871487        elif helpType == 'OldTutorials': # this will go away
    1488             self.frame.Tutorials = True
     1488            #self.frame.Tutorials = True
    14891489            ShowHelp(helpType,self.frame)
    14901490        elif helpType == 'Tutorials':
    14911491            dlg = OpenTutorial(self.frame)
    1492             if dlg.ShowModal() == wx.ID_OK:
    1493                 self.frame.Tutorials = True
     1492            dlg.ShowModal()
     1493            #if dlg.ShowModal() == wx.ID_OK:
     1494                #self.frame.Tutorials = True
    14941495            dlg.Destroy()
    14951496            return
     
    21512152            URL = os.path.join(tutorialPath,'help',tutdir,htmlname)
    21522153            ShowWebPage(URL,self.frame)
     2154            self.frame.ImportDir = os.path.join(tutorialPath,'Exercises',exedir)
    21532155        elif self.BrowseMode == 1:
    21542156            # xfer data locally, open web page remotely
     
    21562158            URL = os.path.join(G2BaseURL,'Tutorials',tutdir,htmlname)
    21572159            ShowWebPage(URL,self.frame)
     2160            self.frame.ImportDir = os.path.join(tutorialPath,'Exercises',exedir)
    21582161        elif self.BrowseMode == 2:
    21592162            # open web page remotely, don't worry about data
    21602163            URL = os.path.join(G2BaseURL,'Tutorials',tutdir,htmlname)
    21612164            ShowWebPage(URL,self.frame)
     2165            self.frame.ImportDir = os.path.join(tutorialPath,'Exercises',exedir)
    21622166        elif self.BrowseMode == 3:
    21632167            # open web page that has already been transferred
  • trunk/config_example.py

    r1709 r1719  
    2828'''
    2929
    30 Enable_logging = None
     30Enable_logging = False
    3131'Set to True to enable use of command logging'
    3232
    33 logging_debug = None
     33logging_debug = False
    3434'Set to True to enable debug for logging'
    3535
     
    4747This will allow users to download tutorial files into their own file space.
    4848'''
     49
     50Starting_directory=None
     51'''Specifies a default location for starting GSAS-II
     52'''
     53
     54Import_directory=None
     55'''Specifies a default location for starting GSAS-II
     56'''
  • trunk/help/gsasII.html

    r1709 r1719  
    23872387links below, but to actually perform the tutorial exercises, the
    23882388sample data needs to be downloaded, which can be done most easily
    2389 using the Help/Tutorials menu command. When that is used, data files
    2390 (and optionally the web pages for off-line use) can be downloaded.
     2389using the
     2390<b style='mso-bidi-font-weight:normal'><span style='font-family:"Calibri","sans-serif";
     2391mso-ascii-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:
     2392Calibri;mso-bidi-theme-font:minor-latin'>Help/Download tutorial
     2393</span></b>
     2394menu entry. When
     2395this menu entry is used from inside GSAS-II (unless browse on web --
     2396data not loaded is selected), data files (and optionally the web pages
     2397for off-line use) are downloaded.
    23912398
    23922399<p><i>Getting started</i><UL>
    23932400<LI><strong><a href="https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/StartingGSASII/Starting GSAS.htm"><span style='font-weight:normal'>Starting GSAS-II
    23942401</span></a></strong>
    2395 (no files)
    2396 </LI>
     2402(no exercise files)</LI>
    23972403
    23982404<li><strong><a href="https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/FitPeaks/Fit Peaks.htm">
    23992405<span style='font-weight:normal'>Fitting individual peaks & autoindexing
    24002406</span></a></strong>
    2401 (<a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/FitPeaks/">files</a>)</li>
     2407(Link to <a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/FitPeaks/">exercise files</a>)</li>
    24022408 
    24032409</ul><p><i>Rietveld fitting</i><ul>
     
    24072413<span style='font-weight:normal'>CW Neutron Powder fit for Yttrium-Iron Garnet
    24082414</span></a></strong>
    2409 (<a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/CWNeutron">files</a>)</li>
     2415(Link to <a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/CWNeutron">exercise files</a>)</li>
    24102416
    24112417<li><strong><a href="https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/LabData/Laboratory X.htm">
    24122418<span style='font-weight:normal'>Fitting laboratory X-ray powder data for fluoroapatite
    24132419</span></a></strong>
    2414 (<a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/LabData">files</a>)</li>
     2420(Link to <a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/LabData">exercise files</a>)</li>
    24152421
    24162422<li><strong><a href="https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/CWCombined/Combined refinement.htm">
    24172423<span style='font-weight:normal'>Combined X-ray/CW-neutron refinement of PbSO4
    24182424</span></a></strong>
    2419 (<a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/CWCombined">files</a>)</li>
     2425(Link to <a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/CWCombined">exercise files</a>)</li>
    24202426
    24212427<li><strong><a href="https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/TOF-CW Joint Refinement/TOF combined XN Rietveld refinement in GSAS.htm">
    24222428<span style='font-weight:normal'>Combined X-ray/TOF-neutron Rietveld refinement
    24232429</span></a></strong>
    2424 (<a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/TOF-CW Joint Refinement">files</a>)</li>
     2430(Link to <a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/TOF-CW Joint Refinement">exercise files</a>)</li>
    24252431
    24262432<li><strong><a href="https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/SeqRefine/SequentialTutorial.htm">
    24272433<span style='font-weight:normal'>Sequential refinement of multiple datasets
    24282434</span></a></strong>
    2429 (<a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/SeqRefine">files</a>)</li>
     2435(Link to <a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/SeqRefine">exercise files</a>)</li>
    24302436
    24312437<li><strong><a href="https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/SeqParametric/ParametricFitting.htm">
    24322438<span style='font-weight:normal'>Parametric Fitting and Pseudo Variables for Sequential Fits
    2433 </span></a></strong> 
    2434 (<a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/SeqParametric">files</a>)</li>
     2439</span></a></strong>
     2440(no exercise files)</LI>
    24352441
    24362442</ul><p><i>Structure solution</i><ul>
     
    24392445<span style='font-weight:normal'>Charge Flipping structure solution for jadarite
    24402446</span></a></strong>
    2441 (<a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/CFjadarite">files</a>)</li>
     2447(no exercise files)</LI>
    24422448
    24432449<li><strong><a href="https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/CFsucrose/Charge Flipping - sucrose.htm">
    24442450<span style='font-weight:normal'>Charge Flipping structure solution for sucrose
    24452451</span></a></strong>
    2446 (<a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/CFsucrose">files</a>)</li>
     2452(no exercise files)</LI>
    24472453
    24482454<li><strong><a href="https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/TOF Charge Flipping/Charge Flipping with TOF single crystal data in GSASII.htm">
    24492455<span style='font-weight:normal'>Charge flipping with neutron TOF single crystal data
    24502456</span></a></strong>
    2451 (<a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/TOF Charge Flipping">files</a>)</li>
     2457(Link to <a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/TOF Charge Flipping">exercise files</a>)</li>
    24522458
    24532459<li><strong><a href="https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/MCsimanneal/MCSA in GSAS.htm">
    24542460<span style='font-weight:normal'>Monte-Carlo simulated annealing structure
    24552461</span></a></strong>
    2456 (<a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/MCsimanneal">files</a>)</li>
     2462(Link to <a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/MCsimanneal">exercise files</a>)</li>
    24572463
    24582464</ul><p><i>Calibration/Image Processing</i><ul>
     
    24612467<span style='font-weight:normal'>Calibration of an area detector
    24622468</span></a></strong>
    2463 (<a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/2DCalibration">files</a>)</li>
     2469(Link to <a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/2DCalibration">exercise files</a>)</li>
    24642470
    24652471<li><strong><a href="https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/2DIntegration/Integration of area detector data in GSAS.htm">
    24662472<span style='font-weight:normal'>Integration of area detector data
    24672473</span></a></strong>
    2468 (<a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/2DIntegration">files</a>)</li>
     2474(no exercise files)</LI>
    24692475
    24702476<li><strong><a href="https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/TOF Calibration/Calibration of a TOF powder diffractometer.htm">
    24712477<span style='font-weight:normal'>Calibration of a Neutron TOF diffractometer
    24722478</span></a></strong>
    2473 (<a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/TOF Calibration">files</a>)</li>
     2479(Link to <a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/TOF Calibration">exercise files</a>)</li>
    24742480       
     2481</ul><p><i>Small-Angle scattering</i><ul>
     2482
     2483<li><strong><a href="https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/SAimages/Small Angle Image Processing.htm">
     2484<span style='font-weight:normal'>Image Processing of small angle x-ray data
     2485</span></a></strong>
     2486(Link to <a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/SAimages">exercise files</a>)</li>
     2487
     2488<li><strong><a href="https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/SAfit/Fitting Small Angle Scattering Data.htm">
     2489<span style='font-weight:normal'>Fitting small angle x-ray data (alumina powder)
     2490</span></a></strong>
     2491(Link to <a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/SAfit">exercise files</a>)</li>
     2492
     2493<li><strong><a href="https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/SAsize/Small Angle Size Distribution.htm">
     2494<span style='font-weight:normal'>Small angle x-ray data size distribution (alumina powder)
     2495</span></a></strong>
     2496(Link to <a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/SAsize">exercise files</a>)</li>
     2497
     2498<li><strong><a href="https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/SAseqref/Sequential Refinement of Small Angle Scattering Data.htm">
     2499<span style='font-weight:normal'>Sequential refinement with small angle scattering data
     2500</span></a></strong>
     2501(Link to <a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/SAseqref">exercise files</a>)</li>
     2502</UL>
     2503
    24752504</ul><p><i>Other</i><ul>
    24762505
     
    24782507<span style='font-weight:normal'>Strain fitting of 2D data
    24792508</span></a></strong>
    2480 (<a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/2DStrain">files</a>)</li>
    2481 
    2482 </ul><p><i>Small-Angle scattering</i><ul>
    2483 
    2484 <li><strong><a href="https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/SAimages/Small Angle Image Processing.htm">
    2485 <span style='font-weight:normal'>Image Processing of small angle x-ray data
    2486 </span></a></strong>
    2487 (<a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/SAimages">files</a>)</li>
    2488 
    2489 <li><strong><a href="https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/SAfit/Fitting Small Angle Scattering Data.htm">
    2490 <span style='font-weight:normal'>Fitting small angle x-ray data (alumina powder)
    2491 </span></a></strong>
    2492 (<a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/SAfit">files</a>)</li>
    2493 
    2494 <li><strong><a href="https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/SAsize/Small Angle Size Distribution.htm">
    2495 <span style='font-weight:normal'>Small angle x-ray data size distribution (alumina powder)
    2496 </span></a></strong>
    2497 (<a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/SAsize">files</a>)</li>
    2498 
    2499 <li><strong><a href="https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/SAseqref/Sequential Refinement of Small Angle Scattering Data.htm">
    2500 <span style='font-weight:normal'>Sequential refinement with small angle scattering data
    2501 </span></a></strong>
    2502 (<a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/SAseqref">files</a>)</li>
    2503 </UL>
     2509(Link to <a href="https://subversion.xray.aps.anl.gov/pyGSAS/Exercises/2DStrain">exercise files</a>)</li>
    25042510
    25052511<p class=MsoNormal><strong><o:p>&nbsp;</o:p></strong></p>
     
    64316437style='mso-bookmark:Pawley'><o:p>&nbsp;</o:p></span></p>
    64326438
    6433 <p class=MsoNormal><span style='mso-bookmark:Pawley'><!-- hhmts start -->Last modified: Sat Mar 14 17:30:03 CDT 2015 <!-- hhmts end -->
     6439<p class=MsoNormal><span style='mso-bookmark:Pawley'><!-- hhmts start -->Last modified: Mon Mar 16 14:54:53 CDT 2015 <!-- hhmts end -->
    64346440</body>
    64356441
Note: See TracChangeset for help on using the changeset viewer.