Changeset 641 for trunk/GSASII.py
- Timestamp:
- May 29, 2012 10:23:48 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r636 r641 243 243 ''' 244 244 self.lastimport = '' 245 self.zipfile = None 245 246 if reader is None: 246 247 multiple = False 247 248 #print "use all formats" 248 249 choices = "any file (*.*)|*.*" 250 choices += "|zip archive (.zip)|*.zip" 249 251 extdict = {} 250 252 # compile a list of allowed extensions … … 269 271 w += "*" + extn 270 272 choices += w + ")|" + w 273 choices += "|zip archive (.zip)|*.zip" 271 274 if not reader.strictExtension: 272 275 choices += "|any file (*.*)|*.*" … … 296 299 rd_list = [] 297 300 for filename in filelist: 298 # set what formats are compatible with this file 301 # is this a zip file? 302 if os.path.splitext(filename)[1].lower() == '.zip': 303 extractedfile = G2IO.ExtractFileFromZip(filename,parent=self) 304 if extractedfile is None: continue # error or Cancel 305 if extractedfile != filename: 306 filename,self.zipfile = extractedfile,filename # now use the file that was created 307 # set what formats are compatible with this file 299 308 primaryReaders = [] 300 309 secondaryReaders = [] … … 596 605 print 'debug: open/read failed',instfile 597 606 pass # fail silently 598 607 608 # did we read the data file from a zip? If so, look there for a 609 # instrument parameter file 610 if self.zipfile: 611 for ext in '.inst','.prm': 612 instfile = G2IO.ExtractFileFromZip( 613 self.zipfile, 614 selection=os.path.split(basename + ext)[1], 615 parent=self) 616 if instfile is not None and instfile != self.zipfile: 617 print 'debug:',instfile,'created from ',self.zipfile 618 Iparm = self.ReadPowderIparm(instfile,bank,numbanks,rd) 619 if Iparm: 620 rd.instfile = instfile 621 rd.instmsg = instfile + ' bank ' + str(rd.instbank) 622 return Iparm 623 else: 624 print 'debug: open/read for',instfile,'from',self.zipfile,'failed' 625 pass # fail silently 626 599 627 while True: # loop until we get a file that works or we get a cancel 600 628 instfile = '' … … 1024 1052 def OnImageRead(self,event): 1025 1053 self.CheckNotebook() 1026 dlg = wx.FileDialog(self, 'Choose image files', '.', '',\ 1027 'Any image file (*.tif;*.tiff;*.mar*;*.avg;*.sum;*.img;*.G2img)\ 1028 |*.tif;*.tiff;*.mar*;*.avg;*.sum;*.img;*.G2img|\ 1029 Any detector tif (*.tif;*.tiff)|*.tif;*.tiff|\ 1030 MAR file (*.mar*)|*.mar*|\ 1031 GE Image (*.avg;*.sum)|*.avg;*.sum|\ 1032 ADSC Image (*.img)|*.img|\ 1033 GSAS-II Image (*.G2img)|*.G2img|\ 1034 All files (*.*)|*.*', 1035 wx.OPEN | wx.MULTIPLE|wx.CHANGE_DIR) 1054 dlg = wx.FileDialog( 1055 self, 'Choose image files', '.', '', 1056 'Any image file (*.tif;*.tiff;*.mar*;*.avg;*.sum;*.img;*.G2img)|' 1057 '*.tif;*.tiff;*.mar*;*.avg;*.sum;*.img;*.G2img;*.zip|' 1058 'Any detector tif (*.tif;*.tiff)|*.tif;*.tiff|' 1059 'MAR file (*.mar*)|*.mar*|' 1060 'GE Image (*.avg;*.sum)|*.avg;*.sum|' 1061 'ADSC Image (*.img)|*.img|' 1062 'GSAS-II Image (*.G2img)|*.G2img|' 1063 'Zip archive (*.zip)|*.zip|' 1064 'All files (*.*)|*.*', 1065 wx.OPEN | wx.MULTIPLE|wx.CHANGE_DIR) 1036 1066 try: 1037 1067 if dlg.ShowModal() == wx.ID_OK: … … 1039 1069 imagefiles.sort() 1040 1070 for imagefile in imagefiles: 1071 # if a zip file, open and extract 1072 if os.path.splitext(imagefile)[1].lower() == '.zip': 1073 extractedfile = G2IO.ExtractFileFromZip(imagefile,parent=self) 1074 if extractedfile is not None and extractedfile != imagefile: 1075 imagefile = extractedfile 1041 1076 Comments,Data,Npix,Image = G2IO.GetImageData(self,imagefile) 1042 1077 if Comments:
Note: See TracChangeset
for help on using the changeset viewer.