#NEWLINE# def run( self ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# if ( self . mode != 'dir' ) : #NEWLINE# #INDENT# args = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if self . path : #NEWLINE# #INDENT# args [ 'InitialDir' ] = os . path . dirname ( self . path ) #NEWLINE# path = os . path . splitext ( os . path . dirname ( self . path ) ) #NEWLINE# args [ 'File' ] = path [ 0 ] #NEWLINE# args [ 'DefExt' ] = path [ 1 ] #NEWLINE# #UNINDENT# args [ 'Title' ] = ( self . title if self . title else 'Pick a file...' ) #NEWLINE# args [ 'CustomFilter' ] = 'Other file types\x00*.*\x00' #NEWLINE# args [ 'FilterIndex' ] = 1 #NEWLINE# filters = '' #NEWLINE# for f in self . filters : #NEWLINE# #INDENT# if ( type ( f ) == str ) : #NEWLINE# #INDENT# filters += ( ( f + '\x00' ) * 2 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# filters += ( ( ( f [ 0 ] + '\x00' ) + ';' . join ( f [ 1 : ] ) ) + '\x00' ) #NEWLINE# #UNINDENT# #UNINDENT# args [ 'Filter' ] = filters #NEWLINE# flags = ( win32con . OFN_EXTENSIONDIFFERENT | win32con . OFN_OVERWRITEPROMPT ) #NEWLINE# if self . multiple : #NEWLINE# #INDENT# flags |= ( win32con . OFN_ALLOWmultiple | win32con . OFN_EXPLORER ) #NEWLINE# #UNINDENT# if self . show_hidden : #NEWLINE# #INDENT# flags |= win32con . OFN_FORCESHOWHIDDEN #NEWLINE# #UNINDENT# args [ 'Flags' ] = flags #NEWLINE# if ( self . mode == 'open' ) : #NEWLINE# #INDENT# ( self . fname , _ , _ ) = win32gui . GetOpenFileNameW ( ** args ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . mode == 'save' ) : #NEWLINE# #INDENT# ( self . fname , _ , _ ) = win32gui . GetSaveFileNameW ( ** args ) #NEWLINE# #UNINDENT# #UNINDENT# if self . fname : #NEWLINE# #INDENT# if self . multiple : #NEWLINE# #INDENT# seq = str ( self . fname ) . split ( '\x00' ) #NEWLINE# ( dir_n , base_n ) = ( seq [ 0 ] , seq [ 1 : ] ) #NEWLINE# self . selection = [ os . path . join ( dir_n , i ) for i in base_n ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . selection = str ( self . fname ) . split ( '\x00' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# ( pidl , display_name , image_list ) = shell . SHBrowseForFolder ( win32gui . GetDesktopWindow ( ) , None , ( self . title if self . title else 'Pick a folder...' ) , 0 , None , None ) #NEWLINE# self . selection = [ str ( shell . SHGetPathFromIDList ( pidl ) ) ] #NEWLINE# #UNINDENT# return self . selection #NEWLINE# #UNINDENT# except ( RuntimeError , pywintypes . error ) : #NEWLINE# #INDENT# return None