File: focus.pl

package info (click to toggle)
libtickit-widgets-perl 0.42-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 568 kB
  • sloc: perl: 5,636; makefile: 2
file content (77 lines) | stat: -rw-r--r-- 1,815 bytes parent folder | download
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
#!/usr/bin/perl

use v5.20;
use warnings;

use Tickit;

use Tickit::Widgets qw( GridBox Frame HBox Entry Static Button CheckButton RadioButton );
Tickit::Style->load_style( <<'EOF' );
Entry:focus {
   bg: "blue";
   b: 1;
}

Frame {
   linetype: "single";
}
Frame:focus-child {
   frame-fg: "red";
}

CheckButton:focus {
   check-bg: "blue";
}

RadioButton:focus {
   tick-bg: "blue";
}
EOF

my $gridbox = Tickit::Widget::GridBox->new(
   style => {
      row_spacing => 1,
      col_spacing => 2,
   },
);

foreach my $row ( 0 .. 2 ) {
   $gridbox->add( $row, 0, Tickit::Widget::Static->new( text => "Entry $row" ) );
   $gridbox->add( $row, 1, Tickit::Widget::Entry->new, col_expand => 1 );
}

{
   $gridbox->add( 3, 0, Tickit::Widget::Static->new( text => "Buttons" ) );
   $gridbox->add( 3, 1, Tickit::Widget::Frame->new()
      ->set_child( my $hbox = Tickit::Widget::HBox->new( spacing => 2 ) ),
   );

   foreach my $label (qw( One Two Three )) {
      $hbox->add( Tickit::Widget::Button->new( label => $label, on_click => sub {} ), expand => 1 );
   }
}

{
   $gridbox->add( 4, 0, Tickit::Widget::Static->new( text => "Checks" ) );
   $gridbox->add( 4, 1, Tickit::Widget::Frame->new()
      ->set_child( my $hbox = Tickit::Widget::HBox->new( spacing => 2 ) )
   );

   foreach ( 0 .. 2 ) {
      $hbox->add( Tickit::Widget::CheckButton->new( label => "Check $_" ) );
   }
}

{
   $gridbox->add( 5, 0, Tickit::Widget::Static->new( text => "Radios" ) );
   $gridbox->add( 5, 1, Tickit::Widget::Frame->new()
      ->set_child( my $hbox = Tickit::Widget::HBox->new( spacing => 2 ) ),
   );

   my $group = Tickit::Widget::RadioButton::Group->new;
   foreach ( 0 .. 2 ) {
      $hbox->add( Tickit::Widget::RadioButton->new( label => "Radio $_", group => $group ) );
   }
}

Tickit->new( root => $gridbox )->run;