943,753 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Unsolved
  • Views: 608
  • Python RSS
Feb 19th, 2009
0

expanding music chooser

Expand Post »
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
Reputation Points: 35
Solved Threads: 32
Posting Pro in Training
leegeorg07 is offline Offline
428 posts
since Jul 2008
Feb 22nd, 2009
0

Re: expanding music chooser

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
Reputation Points: 92
Solved Threads: 156
Practically a Master Poster
jrcagle is offline Offline
608 posts
since Jul 2006
Feb 22nd, 2009
0

Re: expanding music chooser

ermm... that should be tkFileDialog. Sorry. (and who disabled the "Edit" feature?!)

Jeff
Reputation Points: 92
Solved Threads: 156
Practically a Master Poster
jrcagle is offline Offline
608 posts
since Jul 2006
Feb 22nd, 2009
0

Re: expanding music chooser

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.
Reputation Points: 741
Solved Threads: 692
Nearly a Posting Maven
woooee is offline Offline
2,305 posts
since Dec 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: calculating standard deviation
Next Thread in Python Forum Timeline: Need help with simple python problem.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC