Posted to tcl by iobates at Sun Aug 09 22:00:14 GMT 2026view raw

  1. package require Tk
  2.  
  3. wm title . "FileMan"
  4.  
  5. set frame [ttk::frame .f -padding "3 3 12 12"]
  6. grid $frame -column 0 -row 0 -sticky nsew
  7.  
  8. set flist [tk::listbox .f.lb -listvariable lst -width 50 -height 10]
  9. grid $flist -column 1 -row 1 -sticky we
  10.  
  11. grid [ttk::button .f.ebtn -text "Prepare" -command prep] -column 1 -row 2 -sticky we
  12.  
  13. set clist [tk::listbox .f.cl -listvariable clst -width 50 -height 10]
  14. grid $clist -column 2 -row 1 -sticky we
  15. grid [ttk::button .f.cbtn -text "Commit" -command commit] -column 2 -row 2 -sticky we
  16.  
  17.  
  18. proc commit {} {
  19. foreach item $::clst {
  20. puts [eval $item]
  21. }
  22. set ::clst [list ]
  23. }
  24.  
  25. set clst [list ]
  26.  
  27. proc prep {} {
  28. set fil [$::flist curselection]
  29. toplevel .w
  30. wm title .w "Info Box"
  31. ttk::label .w.lbl -text "Choose what this file is"
  32. ttk::button .w.tv -text "Tv" -command {
  33. $clist insert end {*}[format "{exec media -t s -f \"%s\"}" [lindex $lst [$::flist curselection]]]
  34. if {[winfo exists .w]} {
  35. destroy .w
  36. }
  37. }
  38. ttk::button .w.mov -text "Movie" -command {
  39. $clist insert end {*}[format "{exec media -t m -f \"%s\"}" [lindex $lst [$::flist curselection]]]
  40. if {[winfo exists .w]} {
  41. destroy .w
  42. }
  43. }
  44. ttk::button .w.b -text "Book" -command {
  45. $clist insert end {*}[format "{exec media -t b -f \"%s\"}" [lindex $lst [$::flist curselection]]]
  46. if {[winfo exists .w]} {
  47. destroy .w
  48. }
  49. }
  50. ttk::button .w.d -text "test" -command {
  51. $clist insert end {*}[format "{exec media -t d -f \"%s\"}" [lindex $lst [$::flist curselection]]]
  52. if {[winfo exists .w]} {
  53. destroy .w
  54. }
  55. }
  56. pack .w.tv .w.mov .w.b .w.d
  57.  
  58. }
  59.  
  60. proc sort.comp.mtime {a b} {
  61. set ta [file mtime $a]
  62. set tb [file mtime $b]
  63. string compare $a $b
  64. }
  65.  
  66.  
  67. proc with-n-days {} {
  68. set l [list]
  69. set f [glob -directory /mnt/seed/finished/ *]
  70. set t [clock scan "-2 days" -base [clock seconds]]
  71. foreach fl $f {
  72. if { $t < [file mtime $fl] } {
  73. lappend l $fl
  74. }
  75. }
  76. set ::lst l
  77. }
  78.  
  79.  
  80. proc show-files {} {
  81. set f [glob -directory /mnt/seed/finished/ *]
  82. set ::lst $f
  83. }
  84.  
  85. proc every {ms cmd} {
  86. {*}$cmd
  87. after $ms [list after idle [namespace code [info level 0]]]
  88. }
  89.  
  90. bind . <Control-q> {exit}
  91.  
  92. every 5000 show-files
  93.  

Add a comment

Please note that this site uses the meta tags nofollow,noindex for all pages that contain comments.
Items are closed for new comments after 1 week