expanding music chooser

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jul 2008
Posts: 402
Reputation: leegeorg07 is an unknown quantity at this point 
Solved Threads: 31
leegeorg07's Avatar
leegeorg07 leegeorg07 is offline Offline
Posting Pro in Training

expanding music chooser

 
0
  #1
Feb 19th, 2009
i have this code:
import webbrowser, random
import os
import os.path
running = 1
DIR="C:/Documents and Settings/Owner/My Documents/georges poopy/main music/"
music = filter(lambda x: x.lower().endswith("mp3"),os.listdir(DIR))
music = list(music)
choice = int(raw_input("Press 1 to play a new song"))
while running == 1:
    if choice == 1:
        song = random.choice(music)
        webbrowser.open(os.path.join(DIR,song))
    choice = float(raw_input("Press 1 to play a new song"))
that i got with help from the daniweb comunity but i want to expand it so that instead of only choosing from a folder i can just use
DIR="C:/" and also i would like to know if there is a way to remove the
choice = float(raw_input("press 1 to play a new song")) so that it will simply choose a new song at the end of the old one
don't judge me because I'm a year 8!

'it is better to fight for something than to live for nothing'General George S Patton
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 608
Reputation: jrcagle is on a distinguished road 
Solved Threads: 150
jrcagle jrcagle is offline Offline
Practically a Master Poster

Re: expanding music chooser

 
0
  #2
Feb 22nd, 2009
For the file choosing, you should check out the filedialog module. Google for references on it.

For the endless looping, take a look at the code and think about how to remove the element of choice from it.

Jeff
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 608
Reputation: jrcagle is on a distinguished road 
Solved Threads: 150
jrcagle jrcagle is offline Offline
Practically a Master Poster

Re: expanding music chooser

 
0
  #3
Feb 22nd, 2009
ermm... that should be tkFileDialog. Sorry. (and who disabled the "Edit" feature?!)

Jeff
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 1,045
Reputation: woooee is a jewel in the rough woooee is a jewel in the rough woooee is a jewel in the rough 
Solved Threads: 294
woooee woooee is offline Offline
Veteran Poster

Re: expanding music chooser

 
0
  #4
Feb 22nd, 2009
I think you have something like 30 minutes to edit the post. After that it is toggled to off. I suppose to keep old posts from being edited endlessly.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Python Forum
Thread Tools Search this Thread



Tag cloud for Python
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC