Frame放置其他控件的地方

use Tk;
use strict;  
use DBI; 
# Main Window
my $mw = new MainWindow;
my $frm = $mw -> Frame() ->pack;
my $but1 =$frm  -> Button(-text => "view cpu",-width=>300,
-command =>&push_button);
$but1 -> pack();

my $but2 = $frm -> Button(-text => "view memory",-width=>300);

$but2 -> pack();

my $but3 = $frm -> Button(-text => "view disk",-width=>300);

$but3 -> pack();

my $but3 = $frm -> Button(-text => "view Event",-width=>300);

$but3 -> pack();


my $but4 = $frm -> Button(-text => "cleart",-width=>300,-command =>&clear_button);

$but4 -> pack();
#Text Area
my $txt = $frm -> Text(-width=>300, -height=>100) -> pack();
MainLoop;

#This is executed when the button is pressed
sub push_button {
# system("cls");
my $dbName = 'dwh5';  
my $dbUser = 'test';  
my $dbUserPass = 'test';  
my $dbh = DBI->connect("dbi:Oracle:$dbName", $dbUser, $dbUserPass) or die "can't connect to database " ;
my $hostSql = qq{select trim(HOST),trim(FILESYSTEM),trim(TYPE),trim(SIZE#),trim(USED),trim(AVAIL),trim(USE),trim(MOUNTED),to_char(SYSDATE\,'yyyy-mm-dd:Hh24:Mm:Ss') from cpu_info};  
 

my ($a1, $a2, $a3,$a4,$a5,$a6,$a7,$a8,$a9);  
my $selStmt = $dbh->prepare($hostSql);  
$selStmt->bind_columns(undef, $a1, $a2, $a3,$a4,$a5,$a6,$a7,$a8,$a9);  
$selStmt->execute();  
while( $selStmt->fetch() ){  
	#print "$table_name		   $tablespace_name		$status
";  
$txt -> insert("end","$a1	$a2	$a3	$a4	$a5	$a6	$a7	$a8	$a9"."
");
}  
$selStmt->finish;  
$dbh->disconnect; 
}

sub clear_button {
system("cls");
}


#
在框架内放置其他的部件,你可以使用框架部件变量作为parent 通常parent 是$mv 或者是主窗口

但是如果我们希望在框架内放置一个部件,使用frame变量 $frm 代替$mv

原文地址:https://www.cnblogs.com/hzcya1995/p/13351915.html