O'Reilly logo

Mastering Perl/Tk by Nancy Walsh, Stephen Lidie

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a Canvas

It’s easiest to always use the Scrolled method to create a Canvas, unless you know for sure your Canvas is going to be a fixed size that will fit in the window:

$canvas = $mw->Canvas( [ option => values, ... ] )->pack(  );
# or...
$canvas = $mw->Scrolled('Canvas', [ option => values, ... ])->pack(  );

The first line creates just a Canvas and the second creates a Canvas with Scrollbars. (See Chapter 6 for more information on the Scrolled method.) To create a Canvas widget, use the desired parent widget to invoke the Canvas method and pass any initial options in with their values. The Canvas method returns a reference to the newly created Canvas widget.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required