Leser: 3
2 Einträge, 1 Seite |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
use Tk; use Tk::PNG; use strict; use warnings; use FindBin; my $main = new MainWindow; our $DiagramWin; our $DiagramWin_open = 0; my $butShow1 = $main -> Button(-text=>" Show 1 ", -command =>\&butShow1_clicked) ->pack(-side => 'top'); my $butShow2 = $main -> Button(-text=>" Show 2 ", -command =>\&butShow2_clicked) ->pack(-side => 'top'); my $butQuit = $main -> Button(-text=>" Close ", -command =>\&DiagramWin_close) ->pack(-side => 'top'); MainLoop; sub butShow1_clicked { &DiagramWin_show("wetterdiagramm1.png") }; sub butShow2_clicked { &DiagramWin_show("wetterdiagramm2.png") }; sub DiagramWin_show { my $png_filename = shift; if ($DiagramWin_open eq 0) { $DiagramWin = $main -> Toplevel (-title=> "Unterfenster", -width=>1024, -height=>768); $DiagramWin -> OnDestroy(\&DiagramWin_destroyed); } my $canv = $DiagramWin -> Canvas(-width => 1024, -height => 768, -background => 'dark slate gray')->pack; my $diagram = $FindBin::Bin . "/" . $png_filename; $canv -> create ('image', 0, 0, -image => $main->Photo(-file=> $diagram), -anchor => 'nw'); $DiagramWin_open = 1; } sub DiagramWin_close { if ($DiagramWin_open) { $DiagramWin -> destroy(); } $DiagramWin_open = 0; } sub DiagramWin_destroyed { $DiagramWin_open = 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
use Tk; use Tk::PNG; use strict; use warnings; use FindBin; my $main = new MainWindow; our $DiagramWin; our $DiagramWin_open = 0; our $canv; # Canvas auf Unterfenster our $diagram = $main -> Photo(); # leeres Bildobjekt erstellen my $butShow1 = $main -> Button(-text=>" Show 1 ", -command =>\&butShow1_clicked) ->pack(-side => 'top'); my $butShow2 = $main -> Button(-text=>" Show 2 ", -command =>\&butShow2_clicked) ->pack(-side => 'top'); my $butQuit = $main -> Button(-text=>" Close ", -command =>\&DiagramWin_close) ->pack(-side => 'top'); MainLoop; sub butShow1_clicked { &DiagramWin_show("wetterdiagramm1.png") }; sub butShow2_clicked { &DiagramWin_show("wetterdiagramm2.png") }; sub DiagramWin_show { my $png_filename = shift; if ($DiagramWin_open eq 0) # nur aufrufen wenn Fenster noch nicht existiert { $DiagramWin = $main -> Toplevel (-title=> "Unterfenster", -width=>1024, -height=>768); $DiagramWin -> OnDestroy(\&DiagramWin_destroyed); $canv = $DiagramWin -> Canvas(-width => 1024, -height => 768, -background => 'dark slate gray')->pack; $canv -> create ('image', 0, 0, -image => $diagram, -anchor => 'nw'); } $diagram -> configure (-file => $FindBin::Bin . "/" . $png_filename); $DiagramWin -> update(); # Fenster aktualisieren $DiagramWin_open = 1; } sub DiagramWin_close { if ($DiagramWin_open) { $DiagramWin -> destroy(); } } sub DiagramWin_destroyed { $DiagramWin_open = 0; }
2 Einträge, 1 Seite |