Changeset - d19c607c41dc
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 20 years ago 2005-06-13 00:39:03
drewp@bigasterisk.com
font and window sizes, sort songs
1 file changed with 4 insertions and 3 deletions:
0 comments (0 inline, 0 general)
bin/ascoltami
Show inline comments
 
@@ -154,27 +154,27 @@ class Player:
 

	
 
def buildsonglist(root,songfiles,player):
 
    songlist=tk.Frame(root,bd=2,relief='raised',bg='black')
 

	
 
    prefixlen=len(os.path.commonprefix(songfiles))
 
    # include to the last os.sep- dont crop path elements in the middle
 
    prefixlen=songfiles[0].rfind(os.sep)+1 
 
    maxsfwidth=max([len(x[prefixlen:]) for x in songfiles])
 

	
 
    for i,sf in enumerate(songfiles):
 
        b=tk.Button(songlist,text=sf[prefixlen:],width=maxsfwidth,
 
                    anchor='w',pady=0,bd=0,relief='flat',
 
                    font="arial 17 bold")
 
                    font="arial 14 bold")
 
        b.bind("<Configure>",lambda ev,b=b:
 
               b.config(font="arial %d bold" % min(15,int((ev.height-3)*.8))))
 
               b.config(font="arial %d bold" % min(12,int((ev.height-3)*.8))))
 
        try:
 
            # rainbow colors
 
            frac=i/len(songfiles)
 
            b.config(bg='black',
 
                     fg="#%02x%02x%02x" % tuple([int(255*(.7+.3*
 
                                                          math.sin(frac*4+x))
 
                                                     ) for x in 1,2,3]))
 
        except Exception,e:
 
            print "rainbow failed: %s"%e
 
        
 
        b.config(command=lambda sf=sf: player.play(sf))
 
        b.pack(side='top',fill='both',exp=1,padx=0,pady=0,ipadx=0,ipady=0)
 
@@ -310,28 +310,29 @@ class ControlButtons(tk.Frame):
 
            else:
 
                button['bg'] = 'black'
 

	
 
############################
 
        
 
parser=OptionParser()
 

	
 
(options,songfiles)=parser.parse_args()
 

	
 
if len(songfiles)<1:
 
    songfiles = [f for f in os.listdir(showconfig.musicDir())
 
                 if f.endswith('wav')]
 
    songfiles.sort()
 

	
 
root=tk.Tk()
 
root.wm_title("ascoltami")
 
root.wm_geometry("+1270+440")
 
#root.wm_geometry("+1270+440")
 
root.config(bg="black")
 
player=Player(None,None)
 

	
 
songlist = buildsonglist(root,songfiles,player)
 
songlist.pack(fill='both',exp=1)
 

	
 
f2 = tk.Frame(bg='black')
 
buts = ControlButtons(f2)
 
buts.pack(side='top',fill='x')
 

	
 
player.state.trace_variable('w', buts.update_state_buttons)
 
buts.update_state_buttons()
0 comments (0 inline, 0 general)