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
    

  • 相关阅读:
    第六章 函数、谓词、CASE表达式 6-3 CASE表达式
    第六章 函数、谓词、CASE表达式 6-2 谓词
    第六章 函数、谓词、CASE表达式 6-1 各种各样的函数
    第五章 复杂查询 5-3 关联子查询
    第五章 复杂查询 5-2 子查询
    第五章 复杂查询 5-1 视图
    第四章 数据更新 4-3 事务
    第四章 数据库和SQL 4-3 数据的更新(UPDATE语句的使用方法)
    面向对象进阶
    多态
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13351915.html
Copyright © 2011-2022 走看看