[Tk] PowerM (Reproduce mucha musica) By Sokoleonardo
2 participantes
Página 1 de 1.
[Tk] PowerM (Reproduce mucha musica) By Sokoleonardo
Echo en Python (Con el modulo Tk Para interfaz grafica)
Requiere Python 2.5.0, PyAudiere para Py2.5.0, PyWin32api para Py2.5.0 y Numpy.
[Tienes que estar registrado y conectado para ver esa imagen]
Requiere Python 2.5.0, PyAudiere para Py2.5.0, PyWin32api para Py2.5.0 y Numpy.
[Tienes que estar registrado y conectado para ver esa imagen]
- Código:
#!usr/bin/python
# -*- coding: utf-8 -*-
#USE IN PYTHON 2.5.0
#Requiere PyWin32
#Numpy
#PyAudiere
import tkFileDialog, cPickle
from tkMessageBox import showwarning
from platform import system as SystemOperating
from Tkinter import *
from os.path import getsize, exists, splitext
try:
import audiere
except ImportError:
import audiere #if not numpy multi array
if not exists("Save.PowerM"): #debe existir
FILE = open("Save.PowerM","w")
cPickle.dump([None,None,0,True,40,100,"Gray"],FILE)
FILE.close()
def ColectionColors(Color):
Gray = {"Fond":"gray25","ColorBands":"gray20","MarkButtons":"gray10","ColorButtons":"gray40","ColorTextLbFrame":"red",
"ActiveColorButton":"gray15","LetterVar":"green","ResultInfo":"green2","FondListTracks":"gray10","HightLightBGListTracks":"gray25",
"FGListTrackas":"green4","SelectFgListTracks":"orange","repeatTrack":"gray70"}
Dawn = {"Fond":"OrangeRed","ColorBands":"firebrick2","MarkButtons":"red4","ColorButtons":"DarkOrange2","ColorTextLbFrame":"black",
"ActiveColorButton":"DarkOrange","LetterVar":"red2","ResultInfo":"red","FondListTracks":"sienna2","HightLightBGListTracks":"OrangeRed",
"FGListTrackas":"red4","SelectFgListTracks":"black","repeatTrack":"orange"}
Forest = {"Fond":"SeaGreen","ColorBands":"SeaGreen3","MarkButtons":"SpringGreen4","ColorButtons":"SpringGreen","ColorTextLbFrame":"DarkOliveGreen2",
"ActiveColorButton":"SpringGreen4","LetterVar":"green","ResultInfo":"#002800","FondListTracks":"CadetBlue4","HightLightBGListTracks":"SeaGreen",
"FGListTrackas":"DarkOliveGreen2","SelectFgListTracks":"chartreuse","repeatTrack":"green2"}
Gold = {"Fond":"gold3","ColorBands":"gold4","MarkButtons":"yellow4","ColorButtons":"gold","ColorTextLbFrame":"yellow",
"ActiveColorButton":"yellow3","LetterVar":"goldenrod4","ResultInfo":"black","FondListTracks":"wheat3","HightLightBGListTracks":"gold3",
"FGListTrackas":"orange4","SelectFgListTracks":"yellow","repeatTrack":"yellow2"}
Water = {"Fond":"DeepSkyBlue","ColorBands":"DeepSkyBlue3","MarkButtons":"#0a1e78","ColorButtons":"#144682","ColorTextLbFrame":"blue",
"ActiveColorButton":"#0a1e78","LetterVar":"white","ResultInfo":"white","FondListTracks":"aquamarine","HightLightBGListTracks":"DeepSkyBlue",
"FGListTrackas":"blue","SelectFgListTracks":"DeepSkyBlue","repeatTrack":"DeepSkyBlue4"}
if Color == "Gray":
return Gray
elif Color == "Dawn":
return Dawn
elif Color == "Forest":
return Forest
elif Color == "Gold":
return Gold
elif Color == "Water":
return Water
class ConfigColors:
def __init__(self):
self.windowCustomizer = Tk()
self.windowCustomizer.title("Custom PowerM")
self.windowCustomizer.geometry("290x207+300+250")
self.windowCustomizer.resizable(False,False)
try:
icon = "icon.ico" if SystemOperating()=="Windows" else "icon.png"
self.windowCustomizer.iconbitmap(icon)
except: pass
Frame(self.windowCustomizer,width=290,height=400,bg="white").pack()
Label(self.windowCustomizer,text="Custom color",bg="white",font=("Lucida","12","underline")).place(x=95,y=30)
self.ColorButtons = Machine.ButtonOpen["bg"]
self.ColorFond = Machine.Fond["bg"]
self.ButtonColorGray = Button(self.windowCustomizer,text="Gray",bg="gray25",width=7,height=3,command=self.ChangeColorCallGray)
self.ButtonColorGray.place(x=10,y=60)
self.ButtonColorDawn = Button(self.windowCustomizer,text="Dawn",bg="OrangeRed",width=7,height=3,command=self.ChangeColorCallDawn)
self.ButtonColorDawn.place(x=65,y=60)
self.ButtonColorForest = Button(self.windowCustomizer,text="Forest",bg="SeaGreen",width=7,height=3,command=self.ChangeColorCallForest)
self.ButtonColorForest.place(x=120,y=60)
self.ButtonColorGold = Button(self.windowCustomizer,text="Gold",bg="gold3",width=7,height=3,command=self.ChangeColorCallGold)
self.ButtonColorGold.place(x=175,y=60)
self.ButtonColorWater = Button(self.windowCustomizer,text="Water",bg="DeepSkyBlue",width=7,height=3,command=self.ChanngeColorCallWater) #n, ne, e, se, s, sw, w, nw, or center
self.ButtonColorWater.place(x=230,y=60)
self.windowCustomizer.bind("<Destroy>",self.ExitCustom)
#Ilustr:
self.IconProgram = Label(self.windowCustomizer, bg="#143cd2", fg="black", relief="groove", width=17, height=14, anchor="w", bitmap="error")
self.IconProgram.place(x=20,y=120)
self.HeadProgram = Label(self.windowCustomizer, bg="#143cd2", fg="white", text="PowerM :: Stratovarius - Coming Ho...", relief="groove", width=37, height=1, font=("Lucida","7"), anchor="w")
self.HeadProgram.place(x=40,y=120)
self.ExitProgram = Label(self.HeadProgram, bg="#d23c1e", fg="white", text="X", relief="groove", width=3, height=1, font=("Lucida","6"))
self.ExitProgram.place(x=204,y=-1)
self.SizeProgram = Label(self.HeadProgram, bg="#143cd2", fg="blue", text="__", relief="groove", width=3, height=1, font=("Lucida","6"))
self.SizeProgram.place(x=183,y=-1)
self.MinProgram = Label(self.HeadProgram, bg="#143cd2", fg="white", text="__", relief="groove", width=3, height=1, font=("Lucida","6"))
self.MinProgram.place(x=162,y=-1)
self.LeftProgram = Label(self.windowCustomizer, bg="#143cd2", relief="groove", width=1, height=5)
self.LeftProgram.place(x=20,y=138)
self.RightProgram = Label(self.windowCustomizer, bg="#143cd2", relief="groove", width=1, height=5)
self.RightProgram.place(x=256,y=138)
self.BodyProgram = Frame(self.windowCustomizer, bg=self.ColorFond, width=243, height=70)
self.BodyProgram.place(x=22,y=138)
self.ButtonCtrl1 = Label(self.BodyProgram, bg=self.ColorButtons,text="▲", relief="raised", padx=12, height=3, font="{MS Sans Serif} 4")
self.ButtonCtrl1.place(x=0, y=0)
self.ButtonCtrl2 = Label(self.BodyProgram, bg=self.ColorButtons,text="██", relief="raised", padx=10, height=3, font="{MS Sans Serif} 4")
self.ButtonCtrl2.place(x=40, y=0)
self.ButtonCtrl3 = Label(self.BodyProgram, bg=self.ColorButtons,text="►", relief="raised", padx=12, height=3, font="{MS Sans Serif} 4")
self.ButtonCtrl3.place(x=81, y=0)
self.ButtonCtrl4 = Label(self.BodyProgram, bg=self.ColorButtons,text="▌▐", relief="raised", padx=10, height=3, font="{MS Sans Serif} 4")
self.ButtonCtrl4.place(x=121, y=0)
self.ButtonCtrl5 = Label(self.BodyProgram, bg=self.ColorButtons,text="▐◄", relief="raised", padx=9, height=3, font="{MS Sans Serif} 4")
self.ButtonCtrl5.place(x=162, y=0)
self.ButtonCtrl6 = Label(self.BodyProgram, bg=self.ColorButtons,text="►▌", relief="raised", padx=9, height=3, font="{MS Sans Serif} 4")
self.ButtonCtrl6.place(x=204, y=0)
self.ButtonColorGray.bind("<Enter>", self.ChangeColorToGray)
self.ButtonColorDawn.bind("<Enter>", self.ChangeColorToDawn)
self.ButtonColorForest.bind("<Enter>", self.ChangeColorToForest)
self.ButtonColorGold.bind("<Enter>", self.ChangeColorToGold)
self.ButtonColorWater.bind("<Enter>", self.ChangeColorToWater)
for mybutton in (self.ButtonColorGray, self.ButtonColorDawn, self.ButtonColorForest, self.ButtonColorGold, self.ButtonColorWater):
mybutton.bind("<Leave>", self.ChangeColorToNormaly)
def ChangeColorTo(self, ColorButton, ColorFond):
for mybutton in (self.ButtonCtrl1, self.ButtonCtrl2, self.ButtonCtrl3,self.ButtonCtrl4, self.ButtonCtrl5, self.ButtonCtrl6):
mybutton["bg"] = ColorButton
self.BodyProgram["bg"] = ColorFond
def ChangeColorToGray(self, *e):
self.ChangeColorTo("gray40", "gray25")
def ChangeColorToDawn(self, *e):
self.ChangeColorTo("OrangeRed","DarkOrange2")
def ChangeColorToForest(self, *e):
self.ChangeColorTo("SpringGreen","SeaGreen")
def ChangeColorToGold(self, *e):
self.ChangeColorTo("gold","gold3")
def ChangeColorToWater(self, *e):
self.ChangeColorTo("DeepSkyBlue","#144682")
def ChangeColorToNormaly(self, *e):
self.ChangeColorTo(Machine.ButtonOpen["bg"],Machine.Fond["bg"])
def ExitCustom(self,*e):
Machine.CustomOpenON()
def SaveCustom(self,color):
Machine.ColorActualy = color
def ChangeColor(self,Color):
ActualColor = ColectionColors(Color)
ColorFond = ActualColor["Fond"]
ColorBands = ActualColor["ColorBands"]
ColorMarkButtons = ActualColor["MarkButtons"]
ColorButtons = ActualColor["ColorButtons"]
ColorTextLbFrame = ActualColor["ColorTextLbFrame"]
ActiveColorButton = ActualColor["ActiveColorButton"]
LetterVariable = ActualColor["LetterVar"]
ResutlInfo = ActualColor["ResultInfo"]
FondListTracks = ActualColor["FondListTracks"]
highlightBGListTracks = ActualColor["HightLightBGListTracks"]
FGListTrackas = ActualColor["FGListTrackas"]
SelectFGListOFTracks = ActualColor["SelectFgListTracks"]
ColorRepeat = ActualColor["repeatTrack"]
#asign:
Machine.Fond["bg"] = ColorFond
Machine.MarkButtons["bg"] = ColorMarkButtons
for i in (Machine.Band1,Machine.Band2,Machine.Band3,Machine.Band4,Machine.Band5,Machine.Band6,Machine.Band7): i["bg"] = ColorBands
for i in (Machine.ButtonOpen,Machine.ButtonStop,Machine.ButtonPlay,Machine.ButtonPause,Machine.ButtonUpTrack,Machine.ButtonDownTrack,Machine.ButtonAbout):
i["bg"] = ColorButtons; i["activebackground"] = ActiveColorButton
for i in (Machine.TitlePosition,Machine.TitleVolume,Machine.TitleTone,Machine.TitleReproductions,Machine.TitleInfoTrack,Machine.TitleOptionals):
i["bg"] = ColorFond; i["fg"] = ColorTextLbFrame
for i in (Machine.PositionTrack,Machine.VolumeTrack,Machine.ToneTrack):
i["bg"] = ColorFond; i["highlightbackground"] = ColorFond; i["fg"] = LetterVariable; i["activebackground"] = "black"
Machine.ListReproductions["bg"] = FondListTracks
Machine.ListReproductions["highlightbackground"] = highlightBGListTracks
Machine.ListReproductions["fg"] = FGListTrackas
Machine.ListReproductions["selectforeground"] = SelectFGListOFTracks
Machine.CheckButtonRepeat["bg"] = ColorFond
Machine.CheckButtonRepeat["fg"] = ColorRepeat
Machine.CheckButtonRepeat["activebackground"] = ColorFond
Machine.ButtonCustomm["bg"] = ColorButtons; Machine.ButtonCustomm["activebackground"] = ActiveColorButton
for i in (Machine.LabelQuantityList,Machine.LabelLenghtTrack,Machine.LabelSizeTrack): i["bg"] = ColorFond; i["fg"] = ResutlInfo
self.SaveCustom(Color)
self.ChangeColorTo(ColorButtons, ColorFond)
def ChangeColorCallGray(self):
self.ChangeColor("Gray")
def ChangeColorCallDawn(self):
self.ChangeColor("Dawn")
def ChangeColorCallForest(self):
self.ChangeColor("Forest")
def ChangeColorCallGold(self):
self.ChangeColor("Gold")
def ChanngeColorCallWater(self):
self.ChangeColor("Water")
class Body(ConfigColors):
def __init__(self):
self.window = Tk()
self.window.minsize(355,500)
self.window.title("PowerM")
self.window.resizable(False,False)
icon = "icon.ico" if SystemOperating()=="Windows" else "icon.png"
try:
self.window.iconbitmap(icon)
Error_Icon = False
except:
Error_Icon = True
# Load configurations:
LoadConfig = cPickle.load(file("Save.PowerM","r"))
ConfigNames = LoadConfig[0]
ConfigRoutes = LoadConfig[1]
Actualy = LoadConfig[2]
ConfigRepeat = LoadConfig[3]
ConfigVol = LoadConfig[4]
ConfigTone = LoadConfig[5]
self.ColorActualy = LoadConfig[6] # end of load
# aparience:
ActualColor = ColectionColors(self.ColorActualy)
ColorFond = ActualColor["Fond"]
ColorBands = ActualColor["ColorBands"]
ColorMarkButtons = ActualColor["MarkButtons"]
ColorButtons = ActualColor["ColorButtons"]
ColorTextLbFrame = ActualColor["ColorTextLbFrame"]
ActiveColorButton = ActualColor["ActiveColorButton"]
LetterVariable = ActualColor["LetterVar"]
ResutlInfo = ActualColor["ResultInfo"]
FondListTracks = ActualColor["FondListTracks"]
highlightBGListTracks = ActualColor["HightLightBGListTracks"]
FGListTrackas = ActualColor["FGListTrackas"]
SelectFGListOFTracks = ActualColor["SelectFgListTracks"]
ColorRepeat = ActualColor["repeatTrack"]
self.Fond = Frame(self.window,bg=ColorFond,width=355,height=440)
self.Fond.place(x=0,y=60)
self.MarkButtons = Frame(self.window,width=355,bg=ColorMarkButtons,height=66)
self.MarkButtons.place(x=0,y=0)
self.Band1 = Frame(self.window,width=355,bg=ColorBands,height=5)
self.Band1.place(x=0,y=66)
self.Band2 = Frame(self.window,width=355,bg=ColorBands,height=5)
self.Band2.place(x=0,y=150)
self.Band3 = Frame(self.window,width=355,bg=ColorBands,height=5)
self.Band3.place(x=0,y=335)
self.Band4 = Frame(self.window,width=355,bg=ColorBands,height=5)
self.Band4.place(x=0,y=435)
self.Band5 = Frame(self.window,width=5,bg=ColorBands,height=430)
self.Band5.place(x=0,y=71)
self.Band6 = Frame(self.window,width=5,bg=ColorBands,height=430)
self.Band6.place(x=350,y=71)
self.Band7 = Frame(self.window,width=355,bg=ColorBands,height=5)
self.Band7.place(x=0,y=495)
# Botones:
self.ButtonOpen = Button(self.window,activebackground=ActiveColorButton,bg=ColorButtons,text="▲",overrelief="groove",font="Lucida 30",command=self.OpenFiles)
self.ButtonOpen.place(x=0,y=0, height=62, width=54)
self.ButtonStop = Button(self.window,activebackground=ActiveColorButton,bg=ColorButtons,text="██",overrelief="groove",font="Lucida 15",command=self.StopMP3)
self.ButtonStop.place(x=55,y=0, height=62, width=59)
self.ButtonPlay = Button(self.window,activebackground=ActiveColorButton,bg=ColorButtons,text="►",overrelief="groove",font="Lucida 30",command=self.PlayMP3)
self.ButtonPlay.place(x=115,y=0, height=62, width=54)
self.ButtonPause = Button(self.window,activebackground=ActiveColorButton,bg=ColorButtons,text="▌▐",overrelief="groove",font="Lucida 15",command=self.PauseMP3)
self.ButtonPause.place(x=170,y=0, height=62, width=59)
self.ButtonUpTrack = Button(self.window,activebackground=ActiveColorButton,bg=ColorButtons,text="▐◄",overrelief="groove",font="Lucida 15",command=self.ChangeTrackUp)
self.ButtonUpTrack.place(x=230,y=0, height=62, width=62)
self.ButtonDownTrack = Button(self.window,activebackground=ActiveColorButton,bg=ColorButtons,text="►▌",overrelief="groove",font="Lucida 15",command=self.ChangeTrackDown)
self.ButtonDownTrack.place(x=293, y=0, height=62, width=62)
# Etiquetas:
self.TitlePosition = LabelFrame(self.window,fg=ColorTextLbFrame,bg=ColorFond,text="Position",width=175,height=68)
self.TitlePosition.place(x=11,y=71)
self.TitleVolume = LabelFrame(self.window,fg=ColorTextLbFrame,bg=ColorFond,text="Volume",width=75,height=68)
self.TitleVolume.place(x=190,y=71)
self.TitleTone = LabelFrame(self.window,fg=ColorTextLbFrame,bg=ColorFond,text="Tone",width=75,height=68)
self.TitleTone.place(x=270,y=71)
self.TitleReproductions = LabelFrame(self.window,fg=ColorTextLbFrame,bg=ColorFond,text="List of Tracks",width=334,height=170)
self.TitleReproductions.place(x=11,y=155)
self.TitleInfoTrack = LabelFrame(self.window,fg=ColorTextLbFrame,bg=ColorFond,text="Info of Tracks",width=334,height=83)
self.TitleInfoTrack.place(x=11,y=340)
self.TitleOptionals = LabelFrame(self.window,fg=ColorTextLbFrame,bg=ColorFond,text="Optionals",width=334,height=50)
self.TitleOptionals.place(x=11,y=440)
# Scalas:
self.PositionTrack = Scale(self.window,highlightbackground=ColorFond,bg=ColorFond,cursor="sb_h_double_arrow",fg=LetterVariable,orient="horizontal",activebackground="black",sliderrelief="groove",sliderlength=14,troughcolor="gray70",borderwidth=5,command=self.CtrlPosition)
self.PositionTrack.place(x=13,y=85,height=52,width=170)
self.VolumeTrack = Scale(self.window,highlightbackground=ColorFond,bg=ColorFond,cursor="sb_h_double_arrow",fg=LetterVariable,orient="horizontal",activebackground="black",sliderrelief="groove",sliderlength=14,troughcolor="gray70",borderwidth=5,command=self.CtrlVolume)
self.VolumeTrack.place(x=193,y=85,height=52,width=70)
self.VolumeTrack.set(ConfigVol)
self.ToneTrack = Scale(self.window,highlightbackground=ColorFond,bg=ColorFond,cursor="sb_h_double_arrow",fg=LetterVariable,orient="horizontal",activebackground="black",sliderrelief="groove",sliderlength=14,troughcolor="gray70",borderwidth=5,command=self.CtrlTone)
self.ToneTrack.place(x=273,y=85,height=52,width=70)
self.ToneTrack.set(ConfigTone)
# List of Reproduction:
self.ListReproductions = Listbox(self.window,fg=FGListTrackas,selectborderwidth=1,relief="groove",selectforeground=SelectFGListOFTracks,highlightbackground=highlightBGListTracks,bg=FondListTracks,height=9,width=50)
self.ListReproductions.place(x=19,y=170)
self.Listscroll = Scrollbar(self.window,command=self.ListReproductions.yview)
self.Listscroll.place(x=322,y=171,height=148)
self.ListReproductions.configure(yscrollcommand=self.Listscroll.set)
# System Track
self.opener = audiere.open_device()
self.Routes = []
self.Track = None
self.SelectActual = 0
self.window.bind("<KeyPress-Return>",self.RenameSound)
self.window.bind("<KeyPress-Delete>",self.RemoveOneTrack)
self.ListReproductions.bind("<Double-Button-1>",self.RenameSound)
# Label info:
self.LabelQuantityList = Label(self.window,text="Quantity in list:",fg=ResutlInfo,bg=ColorFond)
self.LabelQuantityList.place(x=20,y=360)
self.LabelLenghtTrack = Label(self.window,text="Lenght of track:",fg=ResutlInfo,bg=ColorFond)
self.LabelLenghtTrack.place(x=20,y=380)
self.LabelSizeTrack = Label(self.window,text="Size of track in MB:",fg=ResutlInfo,bg=ColorFond)
self.LabelSizeTrack.place(x=20,y=400)
# Options buttons:
self.AboutONOFF = False
self.ButtonAbout = Button(self.window,bg=ColorButtons,activebackground=ActiveColorButton,text="About",width=7,height=1,command=self.ABOUT)
self.ButtonAbout.place(x=35,y=460)
self.ButtonCustomm = Button(self.window,bg=ColorButtons,activebackground=ActiveColorButton,text="Custom",width=7,height=1,command=self.CustomOpen)
self.ButtonCustomm.place(x=95,y=460)
self.CheckButtonRepeat = Checkbutton(self.window,activebackground=ColorFond,activeforeground="red",selectcolor="black",text="Repeat track",fg=ColorRepeat,bg=ColorFond,command=self.ActiveOnOffRepeat)
self.CheckButtonRepeat.place(x=250,y=460)
self.BoolCheck = True
# Load state:
if ConfigNames:
for i in ConfigNames:
self.ListReproductions.insert(self.ListReproductions.size(),i)
self.Routes = ConfigRoutes
self.SelectActual = Actualy
self.BoolCheck = ConfigRepeat
self.CheckButtonRepeat.select() if self.BoolCheck else self.CheckButtonRepeat.deselect()
#end Load State
self.ActualizationWindow()
self.intVol = int(self.VolumeTrack.get())
self.intTone = int(self.ToneTrack.get())
self.CustomOpenONOFF = False
self.BandaTitle = ""
self.Seleccion = ""
self.slectAfter = 0
self.slectEnd = 25
self.MovePosition()
self.MoveAutomaticOnOff = True
self.MoveTitle()
self.window.bind("<q>", self.OpenFiles)
self.window.bind("<w>", self.StopMP3)
self.window.bind("<e>", self.PlayMP3)
self.window.bind("<r>", self.PauseMP3)
self.window.bind("<t>", self.ChangeTrackUp)
self.window.bind("<y>", self.ChangeTrackDown)
self.window.bind("<Up>", self.VolumeUp)
self.window.bind("<Down>", self.VolumeDown)
self.window.bind("<Left>", self.PositionLeft)
self.window.bind("<Right>", self.PositionRight)
self.window.bind("<s>", self.InvokeButtonRepeatOnOff)
if Error_Icon:
if not exists(icon):
MSG_Error_Icon = "Not name "+icon+" in directory"
else:
MSG_Error_Icon = icon+" corrupt, icon not found"
def ShowErrorView():
showwarning("PowerM-Warning!", MSG_Error_Icon)
self.window.after(1000, ShowErrorView)
def MovePosition(self):
if self.Track:
self.MoveAutomaticOnOff = False
self.PositionTrack.set(self.Track.position * 10 / 100)
self.window.after(ms=1000, func=self.MovePosition)
def ON():
self.MoveAutomaticOnOff = True
self.window.after(ms=100, func=ON)
def MoveTitle(self):
if self.ListReproductions.size():
if len(self.BandaTitle) > 25:
self.Seleccion = self.BandaTitle[self.slectAfter:self.slectEnd]
self.slectAfter += 1
self.slectEnd += 1
self.window.title("PowerM :: ("+self.Seleccion+"...)")
if self.slectEnd > len(self.BandaTitle):
self.Seleccion = ""
self.slectAfter = 0
self.slectEnd = 25
else:
if self.BandaTitle:
self.window.title("PowerM :: ("+self.BandaTitle+")")
else:
self.window.title("PowerM")
if not self.BandaTitle: self.window.title("PowerM")
self.window.after(ms=500, func=self.MoveTitle)
def CheckRepeat(self):
if self.Track:
self.Track.repeating = True if self.BoolCheck else False
def ActiveOnOffRepeat(self):
self.BoolCheck = True if not self.BoolCheck else False
self.CheckRepeat()
def InvokeButtonRepeatOnOff(self, *e):
self.CheckButtonRepeat.invoke()
def ActualizationWindow(self):
if self.Track:
length = str(self.Track.length * 10 / 100)
size = str(float(getsize(self.Routes[self.SelectActual]) / 1024.0 / 1024.0)).split(".")
MBS = size[0]+"."+size[1][0]
else:
length = "None"
MBS = "None"
self.LabelQuantityList["text"] = "Quantity in list: "+str(self.ListReproductions.size())
self.LabelLenghtTrack["text"] = "Lenght of track: "+length
self.LabelSizeTrack["text"] = "Size of track in MB: "+ MBS
self.CtrlPosition("activate")
def OpenFiles(self, *e):
RouteMP3 = tkFileDialog.askopenfilenames(filetypes = (("Songs", ("*.Ogg","*.mp3","*.wav","*.flac","*.aiff","*.mod","*.S3M","*.XM","*.IT")),))
if RouteMP3:
self.window.title("PowerM: Loading...")
for MP3 in RouteMP3:
File = splitext(MP3.split("/")[-1])[0]
if not MP3.upper() in [cap.upper() for cap in self.Routes]:
self.Routes.append(MP3)
self.ListReproductions.insert(self.ListReproductions.size(),File)
self.window.title("PowerM")
self.ActualizationWindow()
def PlayMP3(self, *e):
if self.Track:
if self.Track.playing:
self.Track.reset()
else:
self.Track.play()
self.ActualizationWindow()
self.CtrlPosition("activate")
self.CtrlVolume()
self.CtrlTone()
self.CheckRepeat()
else:
if self.ListReproductions.size():
if self.SelectActual > 0:
self.SelectActual +=1
self.ChangeTrackUp()
elif self.SelectActual == 0:
self.SelectActual -= 1
self.ChangeTrackDown()
def StopMP3(self, *e):
if self.Track:
self.Track.stop()
def PauseMP3(self, *e):
if self.Track:
if self.Track.playing:
self.Track.pause()
else:
self.PlayMP3()
def ChangeTrackUp(self, *e):
end = self.ListReproductions.size()
if end:
if self.SelectActual > 0:
self.StopMP3()
self.ListReproductions.selection_clear(0,end)
self.ListReproductions.select_set(self.SelectActual-1)
self.RenameSound()
self.PlayMP3()
def ChangeTrackDown(self, *e):
end = self.ListReproductions.size()
if end:
if self.SelectActual < end-1:
self.StopMP3()
self.ListReproductions.selection_clear(0,end)
self.ListReproductions.select_set(self.SelectActual+1)
self.RenameSound()
self.PlayMP3()
def CtrlVolume(self,E=None):
self.VolumeTrack["state"] = "normal" if self.Track else "disable"
if self.Track:
vol = int(self.VolumeTrack.get())
self.Track.volume = vol / 100.0
self.intVol = vol
def VolumeUp(self, *e):
self.VolumeTrack.set(int(self.VolumeTrack.get())+1)
def VolumeDown(self, *e):
self.VolumeTrack.set(int(self.VolumeTrack.get())-1)
def CtrlTone(self,E=None):
self.ToneTrack["state"] = "normal" if self.Track else "disable"
if self.Track:
tone = int(self.ToneTrack.get())
self.Track.pitchshift = tone / 100.0
self.intTone = tone
def CtrlPosition(self,E=None):
self.PositionTrack["state"] = "normal" if self.Track else "disable"
if self.Track and E != "activate":
self.PositionTrack["to"] = self.Track.length * 10 / 100
self.PositionTrack["resolution"] = (self.Track.length * 10 / 100) / 100
if self.MoveAutomaticOnOff:
self.Track.position = int(self.PositionTrack.get()) * 100 / 10
def PositionLeft(self, *e):
if self.Track:
self.PositionTrack.set( int(self.PositionTrack.get()) - (self.Track.length * 10 / 100) / 100 )
def PositionRight(self, *e):
if self.Track:
self.PositionTrack.set( int(self.PositionTrack.get()) + (self.Track.length * 10 / 100) / 100 )
def RenameSound(self,play=True):
end = self.ListReproductions.size()
if end:
selected = int(self.ListReproductions.curselection()[0])
self.SelectActual = selected
File = self.Routes[selected]
self.BandaTitle = self.ListReproductions.get(0,"end")[self.SelectActual]
try:
self.Track = self.opener.open_file(File,1)
if play:
self.PlayMP3()
except:
File_fail = File.split("/")[-1]
text = "Not possible open files nick with accent/s or other error ocurred\nplease play other music\nNot open "+File_fail
showwarning("Error in PowerM",text)
self.ActualizationWindow()
self.window.mainloop()
def RemoveOneTrack(self,*e):
if self.ListReproductions.size():
if self.ListReproductions.curselection():
selected = self.Routes[int(self.ListReproductions.curselection()[0])]
self.ListReproductions.delete(int(self.ListReproductions.curselection()[0]))
self.Routes.remove(selected)
if self.SelectActual > 0: self.SelectActual -= 1
if not self.ListReproductions.size():
self.Track = None
self.ActualizationWindow()
def AboutOn(self,*e):
self.AboutONOFF = False
def ABOUT(self):
if not self.AboutONOFF:
textHelp = """
Use Keys:
Q : Open files.
W : Stop track.
E : Play track.
R : Pause track.
T : change track up.
Y : change track down.
UP : Volume level up.
DOWN : Volume level down.
LEFT : Position track left.
RIGHT : Position track left.
S : Button repeat track.
ENTER : Play select track in list.
SUPR : Remove select track in list.
Author: Leonardo A. Reichert as Sokoleonardo
¡Tanks all users!
"""
self.AboutONOFF = True
windowhelp = Tk()
windowhelp.geometry("300x290+300+300")
windowhelp.title("Help in PowerM")
windowhelp.resizable(False,False)
try:
icon = "icon.ico" if SystemOperating()=="Windows" else "icon.png"
windowhelp.iconbitmap(icon)
except: pass
Frame(windowhelp, width=300, height=290, bg=self.Fond["bg"]).pack()
Label(windowhelp, text=textHelp, bg=self.Fond["bg"]).place(x=30,y=0)
windowhelp.bind("<Destroy>",self.AboutOn)
def CustomOpenON(self):
self.CustomOpenONOFF = False
def CustomOpen(self):
if not self.CustomOpenONOFF:
self.CustomOpenONOFF = True
ConfigColors()
def SaveAndExit(self):
if self.Routes:
if not exists("Save.PowerM"): #debe existir
FILE = open("Save.PowerM","w")
cPickle.dump([None,None,0,True,40,100,"Gray"],FILE)
FILE.close()
ListNames = []
ListRoutes = []
for i in self.Routes:
ListRoutes.append(i)
ListNames.append(splitext(i.split("/")[-1])[0])
FILE = open("Save.PowerM","w")
cPickle.dump([ListNames,ListRoutes,self.SelectActual,self.BoolCheck,self.intVol,self.intTone,self.ColorActualy],FILE)
FILE.close()
exit()
Machine = Body()
Machine.window.mainloop()
Machine.SaveAndExit()
Última edición por Sokoleonardo el Jue Ene 05, 2012 7:01 am, editado 6 veces
Sokoleonardo- Moderador de Seccion
- Mensajes : 52
Nivel : 138
Reputación : 4
Fecha de inscripción : 04/08/2011
Vive en : Argentina
Re: [Tk] PowerM (Reproduce mucha musica) By Sokoleonardo
Hey muy bueno Solo le hace falta una interfas grafica mejorada y estaria genial
Muy bueno
Muy bueno
Re: [Tk] PowerM (Reproduce mucha musica) By Sokoleonardo
Na, la interfaz grafica esta perfecta, ademas podes cambiarle de color al programa si deseas hacerlo porque tiene opciones:
Con el boton "custom" accedes a un pequeño panel con 4 botones de colores los cuales dicen: Gray, Dawn, Gray, Forest...
Ademas este programa guarda los cambios echos en el programa:
MusicaActual, ColorActual, Musica/sEnLista, ValoresDeEscalas: Volumen y Tono.
No he visto programas muy bien echo en Python y creo que esto realmente es algo admirable.
Casi nadie usa la interfaz grafica, siempre tienen la tipica "consola negra" para el manejo de cierto codigo.
La consola negra es igual que la CMD de windows.
Saludos!
Con el boton "custom" accedes a un pequeño panel con 4 botones de colores los cuales dicen: Gray, Dawn, Gray, Forest...
Ademas este programa guarda los cambios echos en el programa:
MusicaActual, ColorActual, Musica/sEnLista, ValoresDeEscalas: Volumen y Tono.
No he visto programas muy bien echo en Python y creo que esto realmente es algo admirable.
Casi nadie usa la interfaz grafica, siempre tienen la tipica "consola negra" para el manejo de cierto codigo.
La consola negra es igual que la CMD de windows.
Saludos!
Sokoleonardo- Moderador de Seccion
- Mensajes : 52
Nivel : 138
Reputación : 4
Fecha de inscripción : 04/08/2011
Vive en : Argentina
Re: [Tk] PowerM (Reproduce mucha musica) By Sokoleonardo
si pues en eso tienes razon pero yo se que se podria mejorar un poco el diseño no crees?
Temas similares
» Empeza a usar PowerM by Sokoleonardo (Descargalo ya compilado) 4.2 MB
» [TK] Reproductor de .mp3 by sokoleonardo
» [TK] Manejar PC Automaticamente (Tareas programadas) By sokoleonardo
» [TK] Reproductor de .mp3 by sokoleonardo
» [TK] Manejar PC Automaticamente (Tareas programadas) By sokoleonardo
Página 1 de 1.
Permisos de este foro:
No puedes responder a temas en este foro.
|
|
Vie Sep 05, 2014 6:15 pm por JAVIER_77
» Hacker nostale
Vie Jul 20, 2012 5:02 pm por Sweet_Boy
» Chrome OS 20.x pasa al canal estable
Vie Jul 13, 2012 11:15 pm por [D]ement<<<
» Disponible openSUSE 12.2 RC 1
Vie Jul 13, 2012 12:44 am por [D]ement<<<
» NitroShare, comparte archivos y carpetas entre Linux y Windows
Vie Jul 13, 2012 12:26 am por [D]ement<<<
» Linux Mint 13 KDE Release Candidate, disponible
Vie Jul 13, 2012 12:18 am por [D]ement<<<
» LibreOffice 3.5.5, más estabilidad
Vie Jul 13, 2012 12:06 am por [D]ement<<<
» File History, un Time Machine para Windows 8
Miér Jul 11, 2012 9:50 pm por [D]ement<<<
» Como habilitar el logueo automático en Windows
Miér Jul 11, 2012 9:44 pm por [D]ement<<<
» Acronis True Image 2012
Mar Jul 10, 2012 12:15 am por [D]ement<<<
» Virus Informaticos
Mar Mayo 08, 2012 7:10 am por Sokoleonardo