Reworked the JukeBox earlier today. Now uses a list and not buttons along with the option to change directories.
Screenshot,
And, here's the revised code:
Screenshot,
And, here's the revised code:
#---------------
# jukeBox.tcl
#---------------
#!/bin/sh
#\
exec tclsh "$0" "$@"
package require Gnocl
#---------------
# create playlist
#---------------
proc playList { dir {type ogg} } {
global lst
cd $dir
# clear the existing playlist
$lst erase 0 end
set tracks ""
catch { set tracks [glob *.ogg] }
if {$tracks == ""} {
makeUI [gnocl::fileChooserDialog \
-title "JukeBox: No tracks found. Select Collection Folder.." \
-action openFolder \
-currentFolder $dir ]
}
foreach track [lsort $tracks] {
$lst add [list [list $track]]
}
}
#---------------
# make ui
#---------------
proc makeUI {dir} {
global lst
cd $dir
set cb [gnocl::folderChooserButton \
-title "JukeBox: Select Collection Folder" \
-onFileSet {playList %f}]
set lst [gnocl::list \
-titles {"Track"} \
-types {string } \
-onSelectionChanged {
gnocl::sound [%w get %p 0 ]
}]
playList $dir
set box [gnocl::box -orientation vertical]
$box add $cb
$box add $lst -expand 1 -fill {1 1}
gnocl::window \
-title "JukeBox (1.0)" \
-child $box \
-onDelete exit
}
#---------------
# use specified directory or pick a new one
#---------------
if { $::argc > 0 } {
makeUI $::argv
} else {
# select a directory
makeUI [gnocl::fileChooserDialog \
-title "JukeBox: Select Collection Folder" \
-action openFolder \
-currentFolder $::env(HOME)/Music ]
}
Comments