~ubuntu-branches/ubuntu/natty/perl-tk/natty

« back to all changes in this revision

Viewing changes to demos/demos/widget_lib/mkListbox.pl

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Zander
  • Date: 2004-03-14 13:54:44 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040314135444-prc09u2or4dbr3to
Tags: 1:800.025-2
Add xlibs-dev to Build-Depends:,
Closes: #237942

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
 
3
 
sub mkListbox {
4
 
 
5
 
    # Create a top-level window that displays a listbox with the names of the 50 states.
6
 
 
7
 
    $mkListbox->destroy if Exists($mkListbox);
8
 
    $mkListbox = $top->Toplevel();
9
 
    my $w = $mkListbox;
10
 
    dpos $w;
11
 
    $w->title('Listbox Demonstration (50 states)');
12
 
    $w->iconname('Listbox');
13
 
    $w->minsize(1, 1);
14
 
 
15
 
    my $w_msg = $w->Label(-font => '-Adobe-times-medium-r-normal--*-180-*-*-*-*-*-*', -justify => 'left',
16
 
                           -wraplength => '3.5i', -text => 'A listbox containing the 50 states is displayed below, along ' .
17
 
                           'with a scrollbar.  You can scan the list either using the scrollbar or by dragging in the ' .
18
 
                           'listbox window with button 2 pressed.  Click the "OK" button when you\'ve seen enough.');
19
 
    my $w_frame = $w->Frame(-borderwidth => 10);
20
 
    my $w_ok = $w->Button(-text => 'OK', -width => 8, -command => ['destroy', $w]);
21
 
    $w_msg->pack(-side => 'top');
22
 
    $w_frame->pack(-side => 'top', -expand => 'yes', -fill => 'y');
23
 
    $w_ok->pack(-side => 'bottom');
24
 
 
25
 
    my $w_frame_scroll = $w_frame->Scrollbar();
26
 
    my $w_frame_list = $w_frame->Listbox(-yscrollcommand => ['set', $w_frame_scroll], -setgrid => 1);
27
 
    $w_frame_scroll->configure(-command => ['yview', $w_frame_list]);
28
 
    $w_frame_scroll->pack(-side => 'right', -fill => 'y');
29
 
    $w_frame_list->pack(-side => 'left', -expand => 'yes', -fill => 'both');
30
 
 
31
 
    $w_frame_list->insert(0, qw(Alabama Alaska Arizona Arkansas California Colorado Connecticut Delaware Florida Georgia Hawaii
32
 
                                Idaho Illinois Indiana Iowa Kansas Kentucky Louisiana Maine Maryland Massachusetts Michigan
33
 
                                Minnesota Mississippi Missouri Montana Nebraska Nevada), 'New Hampshire', 'New Jersey',
34
 
                                'New Mexico', 'New York', 'North Carolina', 'North Dakota', qw( Ohio Oklahoma Oregon
35
 
                                Pennsylvania), 'Rhode Island', 'South Carolina', 'South Dakota', qw(Tennessee Texas Utah 
36
 
                                Vermont Virginia Washington), 'West Virginia', 'Wisconsin', 'Wyoming');
37
 
 
38
 
} # end mkListbox
39
 
 
40
 
 
41
 
1;