#!/usr/bin/perl use strict; use warnings 'all'; use Tk; # MainWindow erzeugen my $mw = tkinit(); # Canvas erstellen und platzieren my $c = $mw->Canvas(-background => "white")->grid(-row => 0, -column => 0, -columnspan => 2, -sticky => "ew"); # Canvas strecken(wie -expand bei pack()) $mw->gridColumnconfigure(0, -weight => 1); $mw->gridColumnconfigure(1, -weight => 1); $mw->gridRowconfigure(0, -weight => 1); # Fenster mappen(es wird gezeichnet) $mw->update(); # Breite und Höhe vom Canvas ausgeben print "Breite: ", $c->width(), "\nHoehe: ", $c->height(), "\n"; # Button erstellen, mit dem man immer die aktuelle Größe des Canvas ausgeben kann $mw->Button(-text => "Canvas Größe ausgeben", -command => sub { print "Breite: ", $c->width(), "\nHoehe: ", $c->height(), "\n"})->grid; # MainLoop starten MainLoop;