Schrift
[thread]5063[/thread]

HList und eigene Scrollbar: Perl/Tk

Leser: 1


<< |< 1 2 >| >> 14 Einträge, 2 Seiten
esskar
 2005-08-27 15:04
#44427 #44427
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
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
sub datalist {
$_[0]->{fl2r_datalist} = $_[1] if @_ > 1;
return $_[0]->{fl2r_datalist}
}

sub datalist_scroll_y {
$_[0]->{datalist_scroll_y} = $_[1] if @_ > 1;
return $_[0]->{datalist_scroll_y}
}

sub build_datalist {
my $self = shift;

$self->datalist(
$self->HList(
-columns => 6,
-header => 1,
-height => '15',
-background => 'white',
)->pack(
-fill => 'x',
)
);

$self->datalist_scroll_y(
$self->datalist->Scrollbar(
)->pack(
-side => 'right',
-fill => 'y',
)
);
}


die Hlist ist mit der Scrollbar bar nur noch 1 hoch; ohne die Scrollbar jedoch 15; woran liegt das? (PS: Scrolled will ich nicht nutzen)\n\n

<!--EDIT|esskar|1125140762-->
esskar
 2005-08-27 18:43
#44428 #44428
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
hab das problem mal als lauffähiges programm nachgebaut

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/perl

use strict;
use warnings;

package UserInterface;

use base 'Tk::MainWindow';
require Tk::HList;

my $MinWidth = 640;
my $MinHeight = 480;

sub new {
my ($class) = shift;

my $self = $class->SUPER::new(@_);

$self->build_display;

return ($self);
}

sub run {
my $self = shift;
$self->SUPER::MainLoop;
}

sub center {
my $self = shift;

$self->update;

my $w = $self->width;
my $h = $self->height;

my $posx = int(($self->screenwidth - $w) / 2);
my $posy = int(($self->screenheight - $h) / 2);

$self->geometry($w . 'x' . $h . '+' . $posx . '+' . $posy);
}

sub datalist {
$_[0]->{fl2r_datalist} = $_[1] if @_ > 1;
return $_[0]->{fl2r_datalist}
}

sub datalist_scroll_y {
$_[0]->{fl2r_datalist_scroll_y} = $_[1] if @_ > 1;
return $_[0]->{fl2r_datalist_scroll_y}
}

sub build_display {
my $self = shift;

$self->title("");
$self->geometry($MinWidth .'x'. $MinHeight);
$self->minsize($MinWidth, $MinHeight);
$self->center;

$self->build_datalist;
}

sub build_datalist {
my $self = shift;

$self->datalist(
$self->HList(
-columns => 6,
-header => 1,
-height => '15',
-background => 'white',
)->pack(
-fill => 'x',
)
);

$self->datalist_scroll_y(
$self->datalist->Scrollbar(
)->pack(
-side => 'right',
-fill => 'y',
)
);


my $col = 0;
$self->datalist->headerCreate($col++, -text => '#');
$self->datalist->headerCreate($col++, -text => 'Timestamp');
$self->datalist->headerCreate($col++, -text => 'Thread Id');
$self->datalist->headerCreate($col++, -text => 'Message');

$self->datalist->headerCreate($col++, -text => 'Fipo Start');
$self->datalist->headerCreate($col++, -text => 'Fipo End');
}

1;

my $ui = new UserInterface;
$ui->run;
esskar
 2005-08-29 13:40
#44429 #44429
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
*push*
renee
 2005-08-29 13:53
#44430 #44430
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
So funktioniert es bei mir:
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/perl

use strict;
use warnings;

package UserInterface;

use base 'Tk::MainWindow';
require Tk::HList;

my $MinWidth = 640;
my $MinHeight = 480;

sub new {
my ($class) = shift;

my $self = $class->SUPER::new(@_);

$self->build_display;

return ($self);
}

sub run {
my $self = shift;
$self->SUPER::MainLoop;
}

sub center {
my $self = shift;

$self->update;

my $w = $self->width;
my $h = $self->height;

my $posx = int(($self->screenwidth - $w) / 2);
my $posy = int(($self->screenheight - $h) / 2);

$self->geometry($w . 'x' . $h . '+' . $posx . '+' . $posy);
}

sub datalist {
$_[0]->{fl2r_datalist} = $_[1] if @_ > 1;
return $_[0]->{fl2r_datalist}
}

sub datalist_scroll_y {
$_[0]->{fl2r_datalist_scroll_y} = $_[1] if @_ > 1;
return $_[0]->{fl2r_datalist_scroll_y}
}

sub build_display {
my $self = shift;

$self->title("");
$self->geometry($MinWidth .'x'. $MinHeight);
$self->minsize($MinWidth, $MinHeight);
$self->center;

$self->build_datalist;
}

sub build_datalist {
my $self = shift;
my $hl = $self->HList(
-columns => 6,
-header => 1,
-height => '15',
-background => 'white',
)->pack(
-fill => 'x',
);
$hl->packPropagate(0);


$self->datalist($hl);


$self->datalist_scroll_y(
$self->datalist->Scrollbar(
)->pack(
-side => 'right',
-fill => 'y',
)
);


my $col = 0;
$self->datalist->headerCreate($col++, -text => '#');
$self->datalist->headerCreate($col++, -text => 'Timestamp');
$self->datalist->headerCreate($col++, -text => 'Thread Id');
$self->datalist->headerCreate($col++, -text => 'Message');

$self->datalist->headerCreate($col++, -text => 'Fipo Start');
$self->datalist->headerCreate($col++, -text => 'Fipo End');
}

1;

my $ui = new UserInterface;
$ui->run;


Ich habe das packPropagate(0) verwendet...
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
Arkhen2
 2005-08-29 14:22
#44431 #44431
User since
2005-03-11
25 Artikel
BenutzerIn
[default_avatar]
Scrollt aber nicht !

bei mir gehts so:

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/perl

use strict;
use warnings;

package UserInterface;

use base 'Tk::MainWindow';
require Tk::HList;

my $MinWidth    = 640;
my $MinHeight   = 480;

sub new {
  my ($class) = shift;

  my $self = $class->SUPER::new(@_);

  $self->build_display;

  return ($self);
}

sub run {
  my $self = shift;
  $self->SUPER::MainLoop;
}

sub center {
  my $self = shift;

  $self->update;

  my $w = $self->width;
  my $h = $self->height;

  my $posx = int(($self->screenwidth - $w) / 2);
  my $posy = int(($self->screenheight - $h) / 2);

  $self->geometry($w . 'x' . $h . '+' . $posx . '+' . $posy);
}

sub datalist {
  $_[0]->{fl2r_datalist} = $_[1] if @_ > 1;
  return $_[0]->{fl2r_datalist}
}

sub datalist_scroll_y {
  $_[0]->{fl2r_datalist_scroll_y} = $_[1] if @_ > 1;
  return $_[0]->{fl2r_datalist_scroll_y}
}

sub build_display {
  my $self = shift;
 
  $self->title("");
  $self->geometry($MinWidth .'x'. $MinHeight);
  $self->minsize($MinWidth, $MinHeight);
  $self->center;

  $self->build_datalist;
}

sub build_datalist {
  my $self = shift;

  $self->datalist_scroll_y(
      $self->Scrollbar(
          -orient => 'vertical',
      )->pack(
          -side   => 'right',
          -fill   => 'y'
      )
  );

  $self->datalist(
      $self->HList(
          -columns            => 6,
          -header             => 1,
          #-height             => '15',
          -background         => 'white',
          -yscrollcommand => ['set', $self->datalist_scroll_y]
      )->pack(
          -side   => 'right',
          -fill   => 'both',
          -expand => 1
      )
  );

  $self->datalist_scroll_y->configure(
      -command => ['yview', $self->datalist]
  );

  my $col = 0;
  $self->datalist->headerCreate($col++, -text => '#');
  $self->datalist->headerCreate($col++, -text => 'Timestamp');
  $self->datalist->headerCreate($col++, -text => 'Thread Id');
  $self->datalist->headerCreate($col++, -text => 'Message');
  $self->datalist->headerCreate($col++, -text => 'Fipo Start');
  $self->datalist->headerCreate($col++, -text => 'Fipo End');
 
  for( (0..100) )
  {
      $self->datalist->add($_, -text => $_ );
  }
}

1;

my $ui = new UserInterface;
$ui->run;
renee
 2005-08-29 14:31
#44432 #44432
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
@Arkhen2: Wenn Du aber keine Einträge hast, dann besteht bei Dir das Problem, das schon esskar beschrieben hat... So wird die HList immer groß gezeigt und mit dem Scrollen klappt es auch:
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/perl

use strict;
use warnings;

package UserInterface;

use base 'Tk::MainWindow';
require Tk::HList;

my $MinWidth = 640;
my $MinHeight = 480;

sub new {
my ($class) = shift;

my $self = $class->SUPER::new(@_);

$self->build_display;

return ($self);
}

sub run {
my $self = shift;
$self->SUPER::MainLoop;
}

sub center {
my $self = shift;

$self->update;

my $w = $self->width;
my $h = $self->height;

my $posx = int(($self->screenwidth - $w) / 2);
my $posy = int(($self->screenheight - $h) / 2);

$self->geometry($w . 'x' . $h . '+' . $posx . '+' . $posy);
}

sub datalist {
$_[0]->{fl2r_datalist} = $_[1] if @_ > 1;
return $_[0]->{fl2r_datalist}
}

sub datalist_scroll_y {
$_[0]->{fl2r_datalist_scroll_y} = $_[1] if @_ > 1;
return $_[0]->{fl2r_datalist_scroll_y}
}

sub build_display {
my $self = shift;

$self->title("");
$self->geometry($MinWidth .'x'. $MinHeight);
$self->minsize($MinWidth, $MinHeight);
$self->center;

$self->build_datalist;
}

sub build_datalist {
my $self = shift;


$self->datalist_scroll_y(
$self->Scrollbar(
)->pack(
-side => 'right',
-fill => 'y',
)
);

my $hl = $self->HList(
-columns => 6,
-header => 1,
-height => '15',
-background => 'white',
-yscrollcommand => ['set', $self->datalist_scroll_y]
)->pack(
-fill => 'x',
);
$hl->packPropagate(0);


$self->datalist($hl);

$self->datalist_scroll_y->configure(
-command => ['yview', $self->datalist]
);


my $col = 0;
$self->datalist->headerCreate($col++, -text => '#');
$self->datalist->headerCreate($col++, -text => 'Timestamp');
$self->datalist->headerCreate($col++, -text => 'Thread Id');
$self->datalist->headerCreate($col++, -text => 'Message');

$self->datalist->headerCreate($col++, -text => 'Fipo Start');
$self->datalist->headerCreate($col++, -text => 'Fipo End');

}

1;

my $ui = new UserInterface;
$ui->run;
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
Arkhen2
 2005-08-29 14:41
#44433 #44433
User since
2005-03-11
25 Artikel
BenutzerIn
[default_avatar]
Für feste Höhe 15 würde ich beides auf einen Frame packen,
so hatte ich (hier bei mir) zuerst gemacht.
esskar
 2005-08-29 15:04
#44434 #44434
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
scrollen ist erstmal nicht wichtig, da die HList unendlich viele (virtuelle) Einträge hat&acute;, wobei davon immer nur 10--15 angezeigt werden.

danke.
ptk
 2005-08-29 21:54
#44435 #44435
User since
2003-11-28
3645 Artikel
ModeratorIn
[default_avatar]
Eine LazyHList --- gibt es eine Chance, daraus ein allgemeines Widget zu machen?
esskar
 2005-08-29 22:01
#44436 #44436
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
[quote=ptk,29.08.2005, 19:54]Eine LazyHList --- gibt es eine Chance, daraus ein allgemeines Widget zu machen?[/quote]
willst du sowas?
wenn du willst, mach ich's allgemein und stell es ins cpan!?!

http://www.google.de/search?....zyhlist :)\n\n

<!--EDIT|esskar|1125338644-->
<< |< 1 2 >| >> 14 Einträge, 2 Seiten



View all threads created 2005-08-27 15:04.