Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing the canvas--What am I doing wrong?

Status
Not open for further replies.

hd65

Technical User
Aug 17, 2000
27
US
Hi,
here is what Tk::Canvas doc says;
$canvas-gtpostscript(?option, value, option, value, ...?)
here is what I have;
use strict;
use Tk;
use Tk::Menubutton;
use Tk::Canvas;

my $wow = MainWindow->new;
$wow->title("Printing");
my $wocanvas = $wow->Canvas(-width=>200,-height=>110,
-background=>"white")->pack(
-side=>"top",-anchor=>"n");
my $lowcanvas = $wocanvas->createText(100,20,
-text=>"Here is an example of what\nthe form should look like.",-tags=>"note");
$lowcanvas = $wocanvas->createText(85,60,
-text=>"\nTitle Colors\n Blue\n Green\n Red",
-tags=>"note");
my $rect1 = $wocanvas->createRectangle(80,50,150,35,-tags=>'note');
my $rect2 = $wocanvas->createRectangle(80,68,150,53,-tags=>"note");
my $rect3 = $wocanvas->createRectangle(80,83,150,70,-tags=>"note");
my $rect4 = $wocanvas->createRectangle(80,100,150,85,-tags=>"note");
$wow->Button(-text=>'Clear Work Order',-command=>sub {@wodata=(); $wow->destroy()},
-width=>17)->pack(-anchor=>'center');
$wow->Button(-text=>'Print Work Order',-command=>sub {$lowcanvas->postscript();},
-width=>17)->pack;
}

the button's -command should print the canvas????
I get this error;
Tk::Error: Can't call method "postscript" without a package or object reference
help pls
thanks
paul
 
Could you try some error checking after the call to createText?

$lowcanvas = $wocanvas->createText(85,60,
-text=>"\nTitle Colors\n Blue\n Green\n Red",-tags=>"note") or die "error calling createText\n$!\n"; Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
my bad... I was trying too may things..Here is a simple example of what I'm trying to do...
use strict;
use Tk;
use Tk::Menubutton;
use Tk::Canvas;

my $mw = MainWindow->new;


my $canvas = $mw->Canvas(-width=>200,-height=>110,
-background=>"white")->pack(
-side=>"top",-anchor=>"n");
$canvas->createText(100,20,
-text=>"Here is an example of what\nthe form should look like.",-tags=>"note");
$canvas->createText(85,60,
-text=>"\nTitle Colors\n Blue\n Green\n Red",
-tags=>"note");
$canvas->createRectangle(80,50,150,35,-tags=>'note');
$canvas->createRectangle(80,68,150,53,-tags=>"note");
$canvas->createRectangle(80,83,150,70,-tags=>"note");
$canvas->createRectangle(80,100,150,85,-tags=>"note");
$mw->Button(-text=>'Print Canvas',-command=>sub {$canvas->postscript(
-file=>"testps.out");},-width=>17)->pack;
MainLoop;

all I want is when the canvas printed to a printer when the button is clicked. Is this possible??????

thanks
paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top