I have been reading and experimenting to find the proper way to remove the path of a file when selected using filedialog.askopenfile.
When I select the file (mp3) from the folder I can use a print statement to check the value of the variable, which gives:
I would like to strip all of the path and trailing information so that only the test.mp3 will show when it is used in a Label for the song list.
Currently I have:
I have been reading information about the os.path.spitext and also ntpath.split but have not seen how this can help my sistuation.
A point in the right direction would be appreciated.
When I select the file (mp3) from the folder I can use a print statement to check the value of the variable, which gives:
1 |
<_io.TextIOWrapper name = 'C:/Users/DT2000/Documents/Python Projects/mp3 Player/music/test.mp3' mode = 'r' encoding = 'cp1252' > |
Currently I have:
1 2 3 4 5 6 |
def audio_file(): global recorded_file recorded_file = filedialog.askopenfile(title = 'J.E.C. Software Solutions' , filetypes = [( 'Image Files' , [ '.wav' , '.mp3' , '.vox' ])]) now_playing.insert( 0 ,recorded_file) print (recorded_file) |
A point in the right direction would be appreciated.
"Often stumped... But never defeated."