|
Canvasprintdialog
The canvasprintdialog command creates a print dialog for printing the contents of a canvas widget to a printer or a file. It is possible to specify page orientation, the number of pages to print the image on and if the output should be stretched to fit the page.
For further information, see the Canvasprintdialog
manpage
Components: bbox cpb hull separator
|
wm title . "Canvasprintdialog Example"
##
## These are the attributes of the canvasprintdialog
##
set sz "A4"
set or "landscape"
##=========================================================
## Create the Canvasprintdialog iwidget
##=========================================================
##
iwidgets::Canvasprintdialog .pcd \
-printcmd lpr \
-modality application \
-pagesize $sz \
-orient $or \
-posterize 1 \
-hpagecnt 1 \
-vpagecnt 2 \
-textbackground ghostwhite
##
## Do some configurations of the
## OK and Apply buttons
##
.pcd buttonconfigure OK \
-text Print
.pcd buttonconfigure Apply \
-command ".pcd refresh"
##
## set the geometry for the example canvas
##
set x1 "1.0c"
set x2 "20.0c"
set y1 "1.0c"
set y2 "28.7c"
##
## Build the example canvas (the one to print)
##
pack [canvas .c] \
-expand 1 \
-fill both
.c create rectangle $x1 $y1 $x2 $y2
set y 150
set j 0
while {$j < 3} {
set i 0
set x 150
while {$i < 15} {
set item [.c create oval -50 -50 50 50 -fill red]
.c move $item $x $y
set item [.c create rectangle -10 0 70 100 -fill blue]
.c move $item $x $y
set item [.c create text 10 130 -text TEST!!!!]
.c move $item $x $y
set item [.c create bitmap 20 150 -bitmap hourglass]
.c move $item $x $y
incr x 50
incr i
}
incr y 200
incr j
}
update
##
## tell the canvasprintdialog which canvas to use
##
.pcd setcanvas .c
##
## print if the Print button is pressed
##
if {[.pcd activate]} {
.pcd print
}
|
Download this sample code |
|