[<<] [<] Page 1 of 1 [>] [>>] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
PrimaxGUI & pxscan-0.4
From: Thomas ####@####.#### Date: 7 Feb 2001 12:28:10 -0000 Message-Id: <01020712294400.00731@root> The new version of Gustaf Kroling's pxscan works fine for me. Here is a modified primaxGUI (originally from ####@####.#### in which everything works with pxscan 0.4 except fo the speed slider. (It assumes pxscan is in /usr/local/bin) #!/usr/X11R6/bin/wish8.0 ############################################################################# # Visual Tcl v1.20 Project # ################################# # GLOBAL VARIABLES # global app; global bright; global che32; global che33; global che34; global contrast; global dirce; global gamma; global obj; global pheight; global pposx; global pposy; global pwidth; global res; global sec; global speed; global widget; set widget(about) {.top18} set widget(canvas) {.top17.can20} set widget(help) {.top22} set widget(rev,.top17.can20) {canvas} set widget(rev,.top17.sca39) {speed} set widget(rev,.top18) {about} set widget(rev,.top22) {help} set widget(rev,.top25) {about} set widget(speed) {.top17.sca39} set widget(version) {.top17.fra39.tex17} ################################# # USER DEFINED PROCEDURES # proc init {argc argv} { global sec; global obj; global xposa; global yposa; global xsizea; global ysizea; global pwidth; global pheight; global pposx; global pposy; global app; set app /tmp/scan.sh set pwidth 8.50 set pheight 11.71 set pposx 108 set pposy 147 } init $argc $argv proc {button-down} {sx sy} { global xposa yposa widget obj $widget(canvas) delete $obj set xposa $sx set yposa $sy set obj [$widget(canvas) create rectangle $xposa $yposa $xposa $yposa -outline red] } proc {button-motion} {nx ny} { global xposa yposa widget obj xsizea ysizea set xsizea $nx set ysizea $ny smart-conversion $widget(canvas) coords $obj $xposa $yposa $nx $ny } proc {button-release} {nx ny} { global xposa yposa widget obj $widget(canvas) itemconfigure $obj -outline blue after 1000 $widget(canvas) itemconfigure $obj -outline green } proc {image-preview} {} { global pposx pposy pwidth pheight che33 che34 app set tumb /tmp/tumb set image /tmp/image exec $app -p0x0 -d$pwidth\x$pheight -r 50 $che33 $che34 -n $image >>&/dev/null exec tifftopnm $image >$tumb 2> /dev/null exec rm -f $image if { [ file exists $tumb ] == "1"} { image create photo "scan" -file [file join $tumb]} image create photo "preview" preview copy scan -subsample 2 2 -shrink .top17.can20 create image $pposx $pposy -image preview } proc {main-quit} {} { global app if {[file exists /tmp/tumb ] == "1" } { exec rm -f /tmp/tumb } if {[file exists /tmp/scan.tiff ] == "1" } { exec rm -f /tmp/scan.tiff } if {[file exists /tmp/work ] == "1" } { exec rm -f /tmp/work } exec $app -l off >>&/dev/null if {[file exists /tmp/scan.sh] == "1" } { exec rm -f /tmp/scan.sh } .top17.can20 delete all options-save exit } proc {options-load} {} { global sec res speed bright contrast che32 che33 che34 gamma if {[file exists /usr/local/etc/.rcprimaxGUI ]} { set rcfile [open /usr/local/etc/.rcprimaxGUI r ] set res [gets $rcfile ] set speed [gets $rcfile ] set bright [gets $rcfile ] set contrast [ gets $rcfile ] set gamma [gets $rcfile ] set che32 [gets $rcfile ] set che33 [gets $rcfile ] set che34 [gets $rcfile ] set sec [gets $rcfile ] close $rcfile } else { } } proc {options-save} {} { global sec res speed bright contrast che32 che33 che34 gamma if {[file exists /usr/local/etc/.rcprimaxGUI ]} { file delete -force /usr/local/etc/.rcprimaxGUI } else { } set rcfile [open /usr/local/etc/.rcprimaxGUI a+] puts $rcfile $res puts $rcfile $speed puts $rcfile $bright puts $rcfile $contrast puts $rcfile $gamma puts $rcfile $che32 puts $rcfile $che33 puts $rcfile $che34 puts $rcfile $sec flush $rcfile close $rcfile } proc {save-png} {} { set png [tk_getSaveFile -initialfile scan.png -title "Save as PNG..." ] exec tifftopnm /tmp/scan.tiff > /tmp/temp.pnm 2> /dev/null exec pnmtopng /tmp/temp.pnm >$png 2> /dev/null file delete /tmp/temp.pnm .top17.fra39.lab22 configure -text "PNG saved to: $png" } proc {save-pnm} {} { set pnm [tk_getSaveFile -initialfile scan.pnm -title "PNM save as..." ] exec tifftopnm /tmp/scan.tiff >$pnm 2> /dev/null .top17.fra39.lab22 configure -text "PNM saved to: $pnm" } proc {save-ps} {} { set psc [tk_getSaveFile -initialfile unnamed.ps -title "PS save as..." ] exec tiff2ps /tmp/scan.tiff >$psc 2> /dev/null .top17.fra39.lab22 configure -text "PS saved as: $psc" } proc {save-tiff} {} { set filename [tk_getSaveFile -initialfile scan.tiff -title "Save As.." ] exec cp /tmp/scan.tiff $filename .top17.fra39.lab22 configure -text "Image saved to $filename" } proc {scan-image} {} { global app speed xpos ypos xsize ysize che32 che33 che34 res contrast bright gamma exec $app -p $xpos\x$ypos -d $xsize\x$ysize $che33 $che34 -r $res -c $contrast\/$bright\/$gamma -n /tmp/scan.tiff >>&/dev/null puts "\a" .top17.fra39.lab22 configure -text "Scanning finished.." } proc {smart-conversion} {} { global yposa ysizea xposa xsizea xpos ypos xsize ysize if {[expr $yposa > $ysizea] == "1"} { set ysize [expr ($yposa - $ysizea) / 25.35] set ypos [expr $ysizea / 25.35]} else { set ysize [expr ($ysizea -$yposa) / 25.35] set ypos [expr $yposa / 25.35]} if {[expr $xposa > $xsizea] == "1"} { set xsize [expr ($xposa - $xsizea) / 25.35] set xpos [expr $xsizea / 25.35]} else { set xsize [expr ($xsizea - $xposa) / 25.35] set xpos [expr $xposa / 25.35]} } proc {main} {argc argv} { global widget obj set obj [$widget(canvas) create rectangle 0 0 0 0] if {[ file exists /tmp/scan.sh ] == "1" } { exec rm -f /tmp/scan.sh } exec echo "#! /bin/bash\n# generated by Primax GUI\n/usr/local/bin/pxscan $*\nexit 0" >> /tmp/scan.sh exec chmod 755 /tmp/scan.sh check-run options-load } proc {check-run} {} { global widget if {[file exists /usr/local/etc/.rcprimaxGUI ]} { } else { } } proc {Window} {args} { global vTcl set cmd [lindex $args 0] set name [lindex $args 1] set newname [lindex $args 2] set rest [lrange $args 3 end] if {$name == "" || $cmd == ""} {return} if {$newname == ""} { set newname $name } set exists [winfo exists $newname] switch $cmd { show { if {$exists == "1" && $name != "."} {wm deiconify $name; return} if {[info procs vTclWindow(pre)$name] != ""} { eval "vTclWindow(pre)$name $newname $rest" } if {[info procs vTclWindow$name] != ""} { eval "vTclWindow$name $newname $rest" } if {[info procs vTclWindow(post)$name] != ""} { eval "vTclWindow(post)$name $newname $rest" } } hide { if $exists {wm withdraw $newname; return} } iconify { if $exists {wm iconify $newname; return} } destroy { if $exists {destroy $newname; return} } } } ################################# # VTCL GENERATED GUI PROCEDURES # proc vTclWindow. {base} { if {$base == ""} { set base . } ################### # CREATING WIDGETS ################### wm focusmodel $base passive wm geometry $base 1x1+0+0 wm maxsize $base 1009 738 wm minsize $base 1 1 wm overrideredirect $base 0 wm resizable $base 0 0 wm withdraw $base wm title $base "vt.tcl" ################### # SETTING GEOMETRY ################### } proc vTclWindow.top17 {base} { if {$base == ""} { set base .top17 } if {[winfo exists $base]} { wm deiconify $base; return } ################### # CREATING WIDGETS ################### toplevel $base -class Toplevel \ -highlightbackground #c0c0c0 -highlightcolor #000000 -menu .top17.m17 wm focusmodel $base passive wm geometry $base 434x389+211+195 wm maxsize $base 1000 1000 wm minsize $base 420 420 wm overrideredirect $base 0 wm resizable $base 1 1 wm deiconify $base wm title $base "Primax GUI ver. 0.99-9a" frame $base.fra39 \ -borderwidth 2 -height 75 -highlightbackground #c0c0c0 \ -highlightcolor #000000 -relief groove -width 125 label $base.fra39.lab19 \ -background black \ -font -adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1 \ -foreground #000000 -highlightbackground #c0c0c0 \ -highlightcolor #000000 -relief groove label $base.fra39.lab20 \ -borderwidth 1 \ -font -adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1 \ -foreground #000000 -highlightbackground #c0c0c0 \ -highlightcolor #000000 -text {Scanner Status:} label $base.fra39.lab22 \ -background #18120e -borderwidth 1 \ -font -adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1 \ -foreground #b4b4f0 -highlightbackground #c0c0c0 \ -highlightcolor #000000 -relief raised \ -text {Welcome to Primax GUI 0.99-9a} entry $base.fra39.ent62 \ -background #b4b4f0 \ -font -adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1 \ -foreground #000000 -highlightbackground #a0a0a4 \ -highlightcolor #000000 -selectbackground #000080 \ -selectforeground #ffffff -textvariable sec label $base.fra39.lab63 \ -borderwidth 1 \ -font -adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1 \ -foreground #000000 -highlightbackground #c0c0c0 \ -highlightcolor #000000 \ -text {You can change the Warm-Up time in seconds ...} text $base.fra39.tex17 canvas $base.can20 \ -background #b4b4f0 -borderwidth 1 -height 207 \ -highlightbackground #0e0e0e -highlightcolor #000000 -width 297 bind $base.can20 <B1-Motion> { button-motion %x %y } bind $base.can20 <Button-1> { button-down %x %y } bind $base.can20 <ButtonRelease-1> { button-release %x %y } bind $base.can20 <Double-Button-1> { image-preview } button $base.but23 \ -activebackground #c0c0c0 -activeforeground #000000 -borderwidth 1 \ -command {.top17.can20 delete all} \ -font -adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1 \ -foreground #000000 -highlightbackground #c0c0c0 \ -highlightcolor #0000f8 -padx 9 -pady 3 \ -text {Clear preview window...} menu $base.m17 \ -borderwidth 1 -cursor {} -font {Helvetica -12} $base.m17 add cascade \ -label File -menu .top17.m17.men18 $base.m17 add cascade \ -label Settings -menu .top17.m17.men19 $base.m17 add cascade \ -label Export -menu .top17.m17.men21 $base.m17 add cascade \ -label Help -menu .top17.m17.men22 menu $base.m17.men18 \ -borderwidth 1 -font {Helvetica -12} $base.m17.men18 add command \ \ -command {.top17.fra39.lab19 configure -background red exec $app -l on >>&/dev/null .top17.fra39.lab22 configure -text "Warming Up..." exec sleep $sec puts "\a" .top17.fra39.lab22 configure -text "Scanner ready!"} \ -label {Turn On...} $base.m17.men18 add command \ \ -command {exec $app -l off >>&/dev/null .top17.fra39.lab19 configure -background black .top17.fra39.lab22 configure -text "Scanner Turned Off..."} \ -label {Turn Off...} $base.m17.men18 add command \ \ -command {set filename [ tk_getSaveFile -initialfile scan.tiff -title "Original Save As.."] if {[file exists /tmp/scan.tiff ]} { exec cp /tmp/scan.tiff $filename .top17.fra39.lab22 configure -text "Image saved to: $filename" } else { .top17.fra39.lab22 configure -text "Please scan first!" }} \ -label {Save Image...} $base.m17.men18 add command \ -command main-quit -label Exit $base.m17.men18 add command \ \ -command {exec $app -l on 2>/dev/null puts "\a" .top17.fra39.lab22 configure -text "Scanner Forced to Online" .top17.fra39.lab19 configure -background red} \ -label {Instant Power} menu $base.m17.men19 \ -font {Helvetica -12} $base.m17.men19 add command \ -label Options... $base.m17.men19 add command \ -label {Save current Settings..} menu $base.m17.men21 \ -font {Helvetica -12} $base.m17.men21 add command \ -command save-png -label {Export to PNG ...} $base.m17.men21 add command \ -command save-pnm -label {Export to PNM...} $base.m17.men21 add command \ -command save-ps -label {Export to Postscript...} $base.m17.men21 add command \ -label {Export to ???} menu $base.m17.men22 \ -font {Helvetica -12 } $base.m17.men22 add command \ -label {About GUI...} $base.m17.men22 add command \ -label Commands... scale $base.sca19 \ -borderwidth 1 -font {Helvetica -10} -from -2000.0 -orient horiz \ -to 1000.0 -troughcolor #b4b4f0 -variable contrast -width 10 scale $base.sca20 \ -borderwidth 1 -font {Helvetica -10} -from -200.0 -orient horiz \ -to 200.0 -troughcolor #b4b4f0 -variable bright -width 10 scale $base.sca21 \ -borderwidth 1 -font {Helvetica -10} -from 0.2 -orient horiz \ -resolution 0.1 -to 5.0 -troughcolor #b4b4f0 -variable gamma \ -width 10 scale $base.sca22 \ -activebackground #d9d9d9 -borderwidth 1 -font {Helvetica -10} \ -from 50.0 -orient horiz -resolution 10.0 -to 300.0 \ -troughcolor #b4b4f0 -variable res -width 10 label $base.lab23 \ -borderwidth 1 -font {Helvetica -10} -relief raised -text Contrast: label $base.lab24 \ -borderwidth 1 -font {Helvetica -10} -relief raised -text Brightness: label $base.lab25 \ -borderwidth 1 -font {Helvetica -10} -relief raised -text Gamma: label $base.lab26 \ -borderwidth 1 -font {Helvetica -10} -relief raised -text Resolution: scale $base.sca27 \ -borderwidth 1 -font {Helvetica -10} -from 1.0 -orient horiz -to 15.0 \ -troughcolor #b4b4f0 -variable speed -width 10 label $base.lab28 \ -borderwidth 1 -font {Helvetica -10} -relief raised -text Speed: button $base.but29 \ -background red -foreground #180000 -padx 12 -pady 4 button $base.but30 \ -background green -padx 12 -pady 4 button $base.but31 \ -background blue -padx 12 -pady 4 checkbutton $base.che32 \ \ -command {.top17.but29 configure -background red .top17.but30 configure -background green .top17.but31 configure -background blue .top17.che33 deselect .top17.che34 deselect} \ -font {Helvetica -10} -offvalue {} -onvalue -R -selectcolor #b4b4f0 \ -text {24 bit RGB} -variable che32 checkbutton $base.che33 \ \ -command {.top17.but29 configure -background white .top17.but30 configure -background grey .top17.but31 configure -background black .top17.che32 deselect .top17.che34 deselect} \ -font {Helvetica -10} -offvalue {} -onvalue -G -selectcolor #b4b4f0 \ -text {8 bit Gray} -variable che33 checkbutton $base.che34 \ \ -command {.top17.but29 configure -background white .top17.but30 configure -background black .top17.but31 configure -background white .top17.che32 deselect .top17.che33 deselect} \ -font {Helvetica -10} -offvalue {} -onvalue -B -selectcolor #b4b4f0 \ -text {1 bit B/W} -variable che34 label $base.lab35 \ -borderwidth 1 -font {Helvetica -10} -relief raised -text CHANNELS button $base.but36 \ -borderwidth 1 -command scan-image -font {Helvetica -12} -padx 12 \ -pady 4 -text {Scan selected area:} scale $base.sca39 \ -orient vert label $base.lab18 \ -borderwidth 1 -relief raised -textvariable dirce ################### # SETTING GEOMETRY ################### place $base.fra39 \ -x 3 -y 3 -width 420 -height 70 -anchor nw -bordermode ignore place $base.fra39.lab19 \ -x 106 -y 7 -width 26 -height 13 -anchor nw -bordermode ignore place $base.fra39.lab20 \ -x 5 -y 5 -width 101 -height 18 -anchor nw -bordermode ignore place $base.fra39.lab22 \ -x 12 -y 21 -width 401 -height 18 -anchor nw -bordermode ignore place $base.fra39.ent62 \ -x 12 -y 42 -width 28 -height 22 -anchor nw -bordermode ignore place $base.fra39.lab63 \ -x 45 -y 45 -width 306 -height 18 -anchor nw -bordermode ignore place $base.can20 \ -x 10 -y 80 -width 217 -height 296 -anchor nw -bordermode ignore place $base.but23 \ -x 240 -y 350 -width 188 -height 26 -anchor nw -bordermode ignore place $base.sca19 \ -x 245 -y 88 -width 171 -height 33 -anchor nw -bordermode ignore place $base.sca20 \ -x 245 -y 134 -width 171 -height 31 -anchor nw -bordermode ignore place $base.sca21 \ -x 243 -y 165 -width 106 -height 36 -anchor nw -bordermode ignore place $base.sca22 \ -x 245 -y 195 -anchor nw -bordermode ignore place $base.lab23 \ -x 300 -y 76 -width 61 -height 16 -anchor nw -bordermode ignore place $base.lab24 \ -x 302 -y 123 -width 57 -height 16 -anchor nw -bordermode ignore place $base.lab25 \ -x 354 -y 180 -width 55 -height 16 -anchor nw -bordermode ignore place $base.lab26 \ -x 354 -y 211 -width 55 -height 16 -anchor nw -bordermode ignore place $base.sca27 \ -x 244 -y 225 -width 106 -height 33 -anchor nw -bordermode ignore place $base.lab28 \ -x 354 -y 240 -width 55 -height 16 -anchor nw -bordermode ignore place $base.but29 \ -x 367 -y 260 -width 13 -height 28 -anchor nw -bordermode ignore place $base.but30 \ -x 380 -y 260 -width 13 -height 28 -anchor nw -bordermode ignore place $base.but31 \ -x 393 -y 260 -width 13 -height 28 -anchor nw -bordermode ignore place $base.che32 \ -x 240 -y 260 -anchor nw -bordermode ignore place $base.che33 \ -x 240 -y 280 -anchor nw -bordermode ignore place $base.che34 \ -x 240 -y 300 -anchor nw -bordermode ignore place $base.lab35 \ -x 355 -y 290 -width 63 -height 16 -anchor nw -bordermode ignore place $base.but36 \ -x 240 -y 320 -width 188 -height 26 -anchor nw -bordermode ignore place $base.lab18 \ -x 145 -y 8 -width 271 -height 13 -anchor nw -bordermode ignore } proc vTclWindow.top18 {base} { if {$base == ""} { set base .top18 } if {[winfo exists $base]} { wm deiconify $base; return } ################### # CREATING WIDGETS ################### toplevel $base -class Toplevel \ -background #000000 -highlightbackground #c0c0c0 \ -highlightcolor #000000 wm focusmodel $base passive wm geometry $base 306x246+276+266 wm maxsize $base 1009 738 wm minsize $base 1 1 wm overrideredirect $base 0 wm resizable $base 0 0 wm title $base "About...." label $base.lab20 \ -background #c0c0c0 -borderwidth 1 \ -font -adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1 \ -foreground #000000 -highlightbackground #c0c0c0 \ -highlightcolor #000000 -relief raised \ -text {Hello there. This is just GUI for drivers developed by Marco Foglia which you can reach at : ####@####.#### Drivers cann be downloaded from: http://thor.prohosting.com/~chrordig/Primax/ I hope you enjoy this GUI like me developing it !!! All sugestions and comments are welcome to ####@####.#### --- Of course this project is developed under GPL license so it's Free as hell !} \ -wraplength 250 button $base.but21 \ -activebackground #c0c0c0 -activeforeground #000000 \ -background #c0c0c0 -command {Window hide $widget(about)} \ -font -adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1 \ -foreground #000000 -highlightbackground #c0c0c0 \ -highlightcolor #000000 -padx 9 -pady 3 \ -text {Back to the program...} ################### # SETTING GEOMETRY ################### place $base.lab20 \ -x 8 -y 7 -width 291 -height 188 -anchor nw -bordermode ignore place $base.but21 \ -x 55 -y 205 -width 193 -height 26 -anchor nw -bordermode ignore } proc vTclWindow.top19 {base} { if {$base == ""} { set base .top19 } if {[winfo exists $base]} { wm deiconify $base; return } ################### # CREATING WIDGETS ################### toplevel $base -class Toplevel wm focusmodel $base passive wm geometry $base 324x152+258+358 wm maxsize $base 1009 738 wm minsize $base 1 1 wm overrideredirect $base 0 wm resizable $base 1 1 wm title $base "Settings Editor -Alpha-" entry $base.ent20 label $base.lab21 \ -borderwidth 1 -relief raised -text Port: label $base.lab22 \ -borderwidth 1 -relief raised -text {Temp flename:} entry $base.ent23 ################### # SETTING GEOMETRY ################### place $base.ent20 \ -x 110 -y 5 -anchor nw -bordermode ignore place $base.lab21 \ -x 10 -y 5 -anchor nw -bordermode ignore place $base.lab22 \ -x 10 -y 25 -anchor nw -bordermode ignore place $base.ent23 \ -x 110 -y 25 -anchor nw -bordermode ignore } proc vTclWindow.top23 {base} { if {$base == ""} { set base .top23 } if {[winfo exists $base]} { wm deiconify $base; return } ################### # CREATING WIDGETS ################### toplevel $base -class Toplevel wm focusmodel $base passive wm geometry $base 200x200+565+21 wm maxsize $base 1009 738 wm minsize $base 1 1 wm overrideredirect $base 0 wm resizable $base 1 1 wm title $base "New Toplevel 1" ################### # SETTING GEOMETRY ################### } Window show . Window show .top17 main $argc $argv | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[<<] [<] Page 1 of 1 [>] [>>] |