Reputation: 7780
I have a scrollable canvas who's content i want into a png image.
The problem is I only get a photo of the canvas, missing the non visible part of the canvas at that given time.
How do i get the whole scrollable canvas into a png image?
My current code is the following:
my $canvas_to_get_photo=$mw->Photo(-format=>'Window', -data=>oct($canvas_to_get->id));
$canvas_to_get_photo->write('somepath/image.png', -format=>'png');
Upvotes: 0
Views: 1098
Reputation: 137717
There isn't a native way to do it; Tk only paints to windows, not to image-based surfaces. Your options are therefore to either:
Upvotes: 1
Reputation: 27193
It's been a awhile since I did any heavy Tk work, so this may not work. Have you tried looking for the non-scrolled subcomponent of the scrolled canvas.
IIRC, each 'Scrolled' widget is actually a "mega-widget", with scrollbars, a corner item, and a scrolled item sub-widgets.
So, it may be that you want
my $canvas = $scrolled->Subwidget('widget');
$canvas = $scrolled unless $canvas;
my $canvas_id = $canvas->id;
my $photo = $mw->Photo(-format => 'Window', -data => oct $canvas_id );
$photo->write('somepath/image.png', -format => 'png' );
Upvotes: 1