• 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
    

  • 相关阅读:
    10个实用的但偏执的Java编程技术
    分布式文件系统FastDFS设计原理
    👮 Golang Gin/Ace/Iris/Echo RBAC 鉴权库
    深入浅出爬虫之道: Python、Golang与GraphQuery的对比
    (.*?)
    开箱即用的高匿代理抓取工具
    6.可见性关键字(volidate)
    5.同步关键字(synchronized)
    4.等待和通知
    3.线程优先级
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13351915.html
Copyright © 2020-2023  润新知