Hide and show control : Control Attributes « GUI « Perl

Home
Perl
1.Array
2.CGI
3.Class
4.Data Type
5.Database
6.File
7.GUI
8.Hash
9.Language Basics
10.Network
11.Regular Expression
12.Report
13.Statement
14.String
15.Subroutine
16.System Functions
17.Win32
18.XML
Perl » GUI » Control Attributes 




Hide and show control
 

#!/usr/local/bin/perl -w
use Tk;
use strict;

my $str = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789";

my $mw = MainWindow->new;
my $lframe = $mw->Frame->pack(-fill => 'both', -side => 'left', -expand => 1);
my $lb = $lframe->Scrolled(qw/Listbox -scrollbars e -height 3/)->
                          pack(qw/-fill both -expand -side top/);

$lb->insert('end', sort $mw->fontFamilies);

my $hidebutton = $mw->Button(-text => ">");
$hidebutton->pack(-side => 'left', -fill => 'y');
$hidebutton->configure(
    -command => sub 
  if ($hidebutton->cget(-texteq ">") {
      $lframe->packForget; $hidebutton->configure(-text => "<")
  else {
      $lframe->pack(-before => $hidebutton, -fill => 'both',
        -side => 'left', -expand => 1)
      $hidebutton->configure(-text => ">");
  }
    },
    -font => "courier 8",
);

my $entry = $mw->Entry(
    -textvariable => \$str,
)->pack(-expand => 1, -fill => 'x', -side => 'left');

$lb->bind("<Button>", sub $entry->configure(-font =>
    "{". $lb->get($lb->curselection"} 72")});

MainLoop;

# Causes text to be wrapped around.
sub shift_banner {
    my $newstr = substr($str, 1. substr($str, 01);
    $str = $newstr;
}

   
  














Related examples in the same category
1.Set Button Foreground Color
2.Set Button Text
3.Set Check Box Button Text Value
4.Set Check Box Button onvalue and offvalue
5.Changing Attributes in a Perl/Tk interface
6.Change Button Background Color in Button Action
7.Embeded controls
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.