
Tcl/Tk printing on Windows 95/98
Quote:
> Hi All,
> How to print a content of a Tk listbox or a text window
> to a printer (LPT1) ?
> Thanks in advance.
> Chin Pham
Chin:
If you plan on doing much printing, you will need to get
the printer and gdi packages and install them. I think
I got them off of the neosoft archive. They are included
on the TCL Blast CDROM available from Scriptics. If you
plan on doing much programming w/Tcl/TK, this is something
you should get.
The following may be of help:
-------------------------------------------------
text .text
pack .text
proc file_print { } {
set pdata [.text get 1.0 end]
set fileid [open lpt1 {WRONLY}]
puts $fileid $pdata
close $fileid
Quote:
}
button .q -text "Quit" -command {exit}
button .pr -text "Print" -command {file_print}
pack .q -side right
pack .pr -side left
---------------------------------------------------
Please note, this will print 'raw' data to the printer,
and I didn't take the time to add any formatting or
form feed (you will have to eject paper manually).
Printing from a listbox becomes more complicated, also
do you want to print the whole list, or just the current
selection?
I will hack something out if I get a chance in the next
few days.
Hope this helps.
Steve
--
Steve Offutt Industrial Mold & Tool Co
"The only person that makes no mistakes
is the one who does nothing at all"
:-)
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.