home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 September - Disc 1 / PCNET_CD_2006_09.iso / linux / puppy-barebones-2.01r2.iso / pup_201.sfs / usr / local / bin / xwget.tcl < prev    next >
Encoding:
Tcl/Tk script  |  2006-03-08  |  3.2 KB  |  158 lines

  1. #!/usr/bin/wish
  2.  
  3. #Xwget, a tcl/Tk GUI for wget 
  4. # Ian Mulgrew 2005
  5.  
  6. wm title . "Xwget 0.4 for Puppy"
  7.  
  8. wm minsize . 1 1
  9. # Frame for buttons, log & entry
  10.  
  11. frame .top -width 10c -height 5c 
  12.  
  13. pack .top -side top -fill x
  14.  
  15. #Menu Bar
  16.  
  17. frame .menubar -relief raised -bd 2
  18. pack .menubar -in .top -fill x
  19.  
  20. menubutton .menubar.file -text File -underline 0 -menu .menubar.file.menu
  21. menubutton .menubar.edit -text Edit -underline 0 -menu .menubar.edit.menu
  22. pack .menubar.file .menubar.edit -side left
  23.  
  24. menubutton .menubar.help -text Help -underline 0 -menu .menubar.help.menu
  25. pack .menubar.help -side right
  26.  
  27. menu .menubar.file.menu -tearoff 0
  28. .menubar.file.menu add command -label Quit -command exit
  29.  
  30. menu .menubar.edit.menu -tearoff 0
  31. .menubar.edit.menu add command -label Grab -command grabSel
  32. .menubar.edit.menu add command -label "Clear output log" -command clearOut
  33.  
  34. menu .menubar.help.menu -tearoff 0
  35. .menubar.help.menu add command -label Help -command {exec dillo /usr/local/xwget/xwget_help.html &}
  36. .menubar.help.menu add command -label About -command {exec dillo /usr/local/xwget/xwget_about.html &}
  37.  
  38. ##########################
  39. #Proc for Menus
  40.  
  41. proc clearOut {} {
  42. .log.t delete 1.0 end
  43. }
  44.  
  45. proc grabSel {} {
  46. CopySelection
  47. PasteSelection
  48. }
  49.  
  50. proc CopySelection {} {
  51. global seltxt
  52. set seltxt [selection get STRING]
  53. }
  54.  
  55. proc PasteSelection {} {
  56. global seltxt
  57. .en.filAdres insert insert $seltxt
  58. }
  59.  
  60.  
  61. #Space
  62.  
  63. frame .sp -height 10
  64. pack .sp -in .top -after .menubar
  65.  
  66. #Message frame
  67.  
  68. label .m -text " Please read the Help file first as it contains instructions on how to use Xwget. "
  69. pack .m -in .top -after .sp 
  70.  
  71. frame .spa -height 10
  72. pack .spa -in .top -after .m
  73.  
  74. ###############################################
  75.  
  76. #Download Button
  77.  
  78. button .top.down -text "Download File" -command {
  79.     set fle [.en.filAdres get]
  80.     set ddr [.di.dir get]
  81.     set fa [open "|wget -c -P $ddr $fle" r]
  82.  
  83.  fileevent $fa readable [list Reader $fa]
  84.  
  85. proc Reader { fa } {
  86.     if [eof $fa] {
  87. catch {close $fa}
  88.     .log.t insert end "Download Finished "
  89. } else {
  90.     set thisLine [gets $fa]
  91.     .log.t insert end "$thisLine\n"
  92.     .log.t yview end
  93.     }
  94.     }
  95.  }
  96.  
  97. pack .top.down -side bottom
  98.  
  99. ########################################
  100.  
  101. #Space
  102. frame .spdn -height 10
  103. pack .spdn -in .top -after .top.down
  104.  
  105.  
  106. frame .en -height 10
  107. pack .en -in .top -after .spa
  108.  
  109.  
  110. #Entry label & field
  111.  
  112. label .en.l -text "Enter Address:" -padx 6
  113. entry .en.filAdres -width 65 -bg white -bd 2
  114.  
  115. pack .en.l -side left
  116. pack .en.filAdres -side left -padx 4 -expand true 
  117.  
  118. #Space
  119. frame .spac -height 10
  120. pack .spac -in .top -after .en
  121.  
  122.  
  123. #Directory entry field
  124.  
  125. frame .di -height 10
  126. pack .di -in .top -after .spac
  127.  
  128. label .di.d -text "Enter Directory:" -padx 0
  129. entry .di.dir -width 65 -bg white -bd 2
  130.  
  131. pack .di.d -side left
  132. pack .di.dir -side left -fill x -expand true
  133.  
  134.  
  135. focus .en.filAdres
  136.  
  137. #Space
  138. frame .spacr -height 10
  139. pack .spacr -in .top -after .di
  140.  
  141. # Frame for output log
  142.  
  143. frame .log -relief raised -borderwidth 1
  144. label .log.lb -text "Xwget output log" -padx 0
  145. text .log.t -height 5 -bg white -yscrollc {.log.sb set}
  146. scrollbar .log.sb -command {.log.t yview}
  147.  
  148. pack .log.lb -side top
  149. pack .log.sb -side right -fill y
  150. pack .log.t -side bottom -fill both -expand 1
  151. pack .log -side bottom -fill x 
  152.  
  153. ###############################
  154.  
  155.  
  156.  
  157.  
  158.