zoukankan      html  css  js  c++  java
  • 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
    

  • 相关阅读:
    SPOJ 694 (后缀数组) Distinct Substrings
    POJ 2774 (后缀数组 最长公共字串) Long Long Message
    POJ 3693 (后缀数组) Maximum repetition substring
    POJ 3261 (后缀数组 二分) Milk Patterns
    UVa 1149 (贪心) Bin Packing
    UVa 12206 (字符串哈希) Stammering Aliens
    UVa 11210 (DFS) Chinese Mahjong
    UVa (BFS) The Monocycle
    UVa 11624 (BFS) Fire!
    HDU 3032 (Nim博弈变形) Nim or not Nim?
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13351915.html
Copyright © 2011-2022 走看看