Changeset 1729
- Timestamp:
- Mar 17, 2015 1:34:37 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r1719 r1729 2033 2033 self._init_Macro() 2034 2034 HelpMenu=G2G.MyHelp(self,helpType='Data tree', 2035 morehelpitems=[ ('&Old Tutorials','OldTutorials'), # this will eventually go away2036 ('& Download Tutorial','Tutorials'),2035 morehelpitems=[#('&Old Tutorials','OldTutorials'), # this will eventually go away 2036 ('&Tutorials','Tutorials'), 2037 2037 ]) 2038 2038 menubar.Append(menu=HelpMenu,title='&Help') -
trunk/GSASIIctrls.py
r1722 r1729 1485 1485 print 'Error: help lookup failed!',event.GetEventObject() 1486 1486 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) 1490 1489 elif helpType == 'Tutorials': 1491 1490 dlg = OpenTutorial(self.frame) 1492 1491 dlg.ShowModal() 1493 #if dlg.ShowModal() == wx.ID_OK:1494 #self.frame.Tutorials = True1495 1492 dlg.Destroy() 1496 1493 return … … 1728 1725 self.dlg.SetSizer(mainSizer) 1729 1726 mainSizer.Fit(self.dlg) 1727 self.dlg.CenterOnParent() 1730 1728 self.dlg.ShowModal() 1731 1729 self.dlg.Destroy() … … 2020 2018 tutorialPath = GSASIIpath.GetConfigValue('Tutorial_location') 2021 2019 else: 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')) 2023 2025 2024 2026 class OpenTutorial(wx.Dialog): … … 2037 2039 pnl = wx.Panel(self) 2038 2040 sizer = wx.BoxSizer(wx.VERTICAL) 2041 sizer1 = wx.BoxSizer(wx.HORIZONTAL) 2039 2042 label = wx.StaticText( 2040 2043 pnl, wx.ID_ANY, 2041 2044 'Select the tutorial to be run and the mode of access' 2042 2045 ) 2043 sizer.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)2044 2046 msg = '''To save download time for GSAS-II tutorials and their 2045 2047 sample data files are being moved out of the standard … … 2061 2063 ''' 2062 2064 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)) 2064 2071 #====================================================================== 2065 2072 # # This is needed only until we get all the tutorials items moved … … 2081 2088 self.mode.Bind(wx.EVT_RADIOBOX, self.OnModeSelect) 2082 2089 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)) 2083 2097 sizer1 = wx.BoxSizer(wx.HORIZONTAL) 2084 2098 btn = wx.Button(pnl, wx.ID_ANY, "Set download location") … … 2092 2106 'Tutorials and Exercise files will be downloaded to:' 2093 2107 ) 2094 sizer.Add(label, 0, wx.ALIGN_LEFT|wx.ALL, 5)2108 sizer.Add(label, 0, wx.ALIGN_LEFT|wx.ALL, 1) 2095 2109 self.TutorialLabel = wx.StaticText(pnl,wx.ID_ANY,'') 2096 2110 sizer.Add(self.TutorialLabel, 0, wx.ALIGN_LEFT|wx.EXPAND, 5) 2097 2111 self.ExerciseLabel = wx.StaticText(pnl,wx.ID_ANY,'') 2112 sizer.Add(self.ExerciseLabel, 0, wx.ALIGN_LEFT|wx.EXPAND, 5) 2098 2113 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)2102 2114 self.OnModeSelect(None) 2103 #self.FillListBox()2104 sizer.Add(self.listbox,1,WACV|wx.EXPAND|wx.ALL,1)2105 2115 2106 2116 btnsizer = wx.StdDialogButtonSizer() … … 2117 2127 # ''' 2118 2128 # self.EndModal(wx.ID_OK) 2119 # self.frame.Tutorials = True2120 2129 # ShowHelp('Tutorials',self.frame) 2121 2130 def OnModeSelect(self,event): … … 2161 2170 self.LoadExercise(exedir,tutorialPath,G2BaseURL) 2162 2171 URL = os.path.join(tutorialPath,'help',tutdir,htmlname) 2172 self.frame.ImportDir = os.path.join(tutorialPath,'Exercises',exedir) 2163 2173 ShowWebPage(URL,self.frame) 2164 self.frame.ImportDir = os.path.join(tutorialPath,'Exercises',exedir)2165 2174 elif self.BrowseMode == 1: 2166 2175 # xfer data locally, open web page remotely 2167 2176 self.LoadExercise(exedir,tutorialPath,G2BaseURL) 2168 2177 URL = os.path.join(G2BaseURL,'Tutorials',tutdir,htmlname) 2178 self.frame.ImportDir = os.path.join(tutorialPath,'Exercises',exedir) 2169 2179 ShowWebPage(URL,self.frame) 2170 self.frame.ImportDir = os.path.join(tutorialPath,'Exercises',exedir)2171 2180 elif self.BrowseMode == 2: 2172 2181 # open web page remotely, don't worry about data 2173 2182 URL = os.path.join(G2BaseURL,'Tutorials',tutdir,htmlname) 2174 2183 ShowWebPage(URL,self.frame) 2175 self.frame.ImportDir = os.path.join(tutorialPath,'Exercises',exedir)2176 2184 elif self.BrowseMode == 3: 2177 2185 # open web page that has already been transferred 2178 2186 URL = os.path.join(tutorialPath,'help',tutdir,htmlname) 2187 self.frame.ImportDir = os.path.join(tutorialPath,'Exercises',exedir) 2179 2188 ShowWebPage(URL,self.frame) 2180 2189 else: … … 2194 2203 throws an exception if there is a problem. 2195 2204 ''' 2205 wx.BeginBusyCursor() 2206 wx.Yield() 2196 2207 if os.path.exists(fullpath): 2197 2208 if os.path.exists(os.path.join(fullpath,"help")): 2198 2209 if not GSASIIpath.svnGetRev(os.path.join(fullpath,"help")): 2199 2210 print("Problem with "+fullpath+" dir help exists but is not in SVN") 2211 wx.EndBusyCursor() 2200 2212 raise Exception 2201 2213 if os.path.exists(os.path.join(fullpath,"Exercises")): 2202 2214 if not GSASIIpath.svnGetRev(os.path.join(fullpath,"Exercises")): 2203 2215 print("Problem with "+fullpath+" dir Exercises exists but is not in SVN") 2216 wx.EndBusyCursor() 2204 2217 raise Exception 2205 2218 if (os.path.exists(os.path.join(fullpath,"help")) and 2206 2219 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() 2207 2225 return True # both good 2208 2226 elif (os.path.exists(os.path.join(fullpath,"help")) or 2209 2227 os.path.exists(os.path.join(fullpath,"Exercises"))): 2210 2228 print("Problem: dir "+fullpath+" exists has either help or Exercises, not both") 2229 wx.EndBusyCursor() 2211 2230 raise Exception 2212 wx.BeginBusyCursor()2213 2231 if not GSASIIpath.svnInstallDir(baseURL+"/MT",fullpath): 2214 2232 wx.EndBusyCursor() … … 2237 2255 ''' 2238 2256 global tutorialPath 2239 localpath = os.path.abspath(os.path.expanduser('~/G2tutorials'))2240 2257 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) 2242 2259 #) 2243 if dlg.ShowModal() == wx.ID_OK: 2260 try: 2261 if dlg.ShowModal() != wx.ID_OK: 2262 return 2244 2263 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 2250 2267 if not os.path.exists(pth): 2251 2268 try: … … 2262 2279 except: 2263 2280 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...") 2265 2286 2266 2287 You must use a directory that you have write access 2267 2288 to. You can reuse a directory previously used for 2268 2289 downloads, but the help and Tutorials subdirectories 2269 must becreated by this routine.2290 must have been created by this routine. 2270 2291 ''') 2271 2292 self.dataLoc.SetLabel(tutorialPath) 2272 2293 self.ShowTutorialPath() 2294 self.OnModeSelect(None) 2273 2295 2274 2296 if __name__ == '__main__': -
trunk/GSASIIpath.py
r1701 r1729 378 378 '--accept','theirs-conflict','--force'] 379 379 if svnVersionNumber() > 1.6: cmd += ['--ignore-ancestry'] 380 print("Loading files from "+URL )380 print("Loading files from "+URL+'\n to '+fpath) 381 381 s = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE) 382 382 out,err = s.communicate() -
trunk/config_example.py
r1719 r1729 39 39 Tutorial_location = None 40 40 '''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 42 location (such as to use the GSASII installation directory), this can be set here. 43 As an example, to always use ~/G2tutorials do this:: 43 44 44 45 import os.path 45 46 Tutorial_location = os.path.join(os.path.expanduser('~'),'G2tutorials') 46 47 47 This will allow users to download tutorial files into their own file space. 48 To install into the location where GSAS-II is installed, use this:: 49 50 import GSASIIpath 51 Tutorial_location = GSASIIpath.path2GSAS2 52 48 53 ''' 49 54
Note: See TracChangeset
for help on using the changeset viewer.