Thread eigene Klasse mit Tk, Anfänger (3 answers)
Opened by jetcki at 2010-07-09 11:28

jetcki
 2010-07-09 11:28
#139698 #139698
User since
2010-07-09
6 Artikel
BenutzerIn
[default_avatar]
Hallo Zusammen,

nach langer Suche konnte ich hier keine Lösung für mein Ansatz finden.
Beim ausführen bekomme ich die Fehlermeldung:
Quote
Undefined subroutine &window::Mainloop called at window.pm line 35

Was mache ich falsch?

Code: (dl )
1
2
3
4
5
6
7
8
9
#!/usr/bin/perl -w
use strict;
use warnings;
use window;

my $wm= window->new();
$wm->set_xy(128,133);
$wm->set_tittle('program');
$wm->set_window();


Code: (dl )
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
package window;

use strict;
use warnings;
use Tk;

sub new {
my $this = shift;
my $self = {};
bless ($self, $this);
return $self;
}

sub set_xy {
my $this = shift;
if(@_) {$this->{'windowHeight'} = shift};
if(@_) {$this->{'windowWidth'} = shift};
}

sub set_tittle {
my $this = shift;
if(@_) {$this->{'tittle'} = shift};
}

sub set_window {
my $this = shift;
my $mw = MainWindow->new();
$mw->title($this->{'tittle'});
my $screenHeight = $mw->screenheight;
my $screenWidth = $mw->screenwidth;
$mw->geometry($this->{'windowWidth'} . "x" . $this->{'windowHeight'});
$mw->geometry("+" . int($screenWidth/2 -
$this->{'windowWidth'}/2) . "+" . int($screenHeight/2 -
$this->{'windowHeight'}/2));
Mainloop();
}

Last edited: 2010-07-09 11:37:00 +0200 (CEST)

View full thread eigene Klasse mit Tk, Anfänger