rossiya has asked for the wisdom of the Perl Monks concerning the following question:

I made a graph with:
$image = $mainWindow -> Photo('image2', -file => 'composite.jpeg'); $graph = $mainWindow -> PlotDataset<br> ( #-width => 1304, -width => 1304, -height => 500, -background => 'snow', -tile => $image, -autoScaleX => "Off", -autoScaleY => "Off", #-autoScaleY1 => "Off", ) -> pack(-fill => 'both', -expand => 1);

Then later I want to replace with the image composite2.jpeg:

$image->delete; $image = $mainWindow -> Photo('image3', -file => 'composite2.jpeg' +); #$mainWindow->configure(-tile => 'image3'); $graph->configure(-tile => 'image3');

But the old image remains tiled in the background. Is there a way to dynamically replace the tiled image, without recreating the canvas? Or am I approaching the problem wrong? Should I make a frame in the background instead? If so, how would I always keep the frame below my graph canvas?

Replies are listed 'Best First'.
Re: Reloading a perltk canvas tile
by liverpole (Monsignor) on Oct 09, 2007 at 15:41 UTC
    Hi rossiya,

    Try using packForget at the place in the code where you want to remove it:

    $graph->packForget();

    That should take it out of the window from which it's being managed.


    s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/
      Thanks, I didn't know about packForget(). Here $graph is just a Tk::PlotDataset canvas so $graph->packForget() essentially wipes it out. I will try layering canvases, but for my simple needs drawing the image first, then overwriting with the plot in a single canvas does the trick. But I came across Tk::Zinc thanks to your suggestion. I may become hooked on that, based on the screenshot eye candy.
Re: Reloading a perltk canvas tile
by zentara (Cardinal) on Oct 09, 2007 at 15:53 UTC
    I don't know what PlotDataset is, please show a working code snippet. You talk about a canvas, but no canvas is shown in your pseudocode. You could make a canvas with a Photo as a background, then overlay it with another Photo, then use the canvas->raise() method to keep it on top,

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum