• Perl Tk grid 布局


    <pre name="code" class="sql">#!/usr/local/bin/perl
    use Tk;
    use dbi;
    #Global Variables
    my $age = 10;
    # Main Window
    my $mw = new MainWindow;
    #GUI Building Area
    
    
    #Age
    
    my $but1 = $mw -> Button(-text=>"view cpu", -command =>&push_button1); ## 执行函数push_butto
    my $but2 = $mw -> Button(-text=>"view memory", -command =>&push_button2); ## 执行函数push_butto
    my $but3 = $mw -> Button(-text=>"view disk", -command =>&push_button3); ## 执行函数push_butto
    my $but4 = $mw -> Button(-text=>"view err", -command =>&push_button4); ## 执行函数push_butto
    my $but5 = $mw -> Button(-text=>"view syslog", -command =>&push_button5); ## 执行函数push_butto
    my $but6 = $mw -> Button(-text=>"view event", -command =>&push_button6); ## 执行函数push_butto
    
    #Text Area
    my $textarea = $mw -> Frame();
    my $txt = $textarea -> Text(-width=>200, -height=>100);
    
    my $srl_y = $textarea -> Scrollbar(-orient=>'v',-command=>[yview => $txt]);  ##Scrollbar滚动条垂直 
    
    my $srl_x = $textarea -> Scrollbar(-orient=>'h',-command=>[xview => $txt]);
    
    $txt -> configure(-yscrollcommand=>['set', $srl_y], ##yscrollcommand文本部件和滚动条通讯
    
    -xscrollcommand=>['set',$srl_x]);
    #Geometry Management
    #columnspan=>2 占据的列数
    
    $but1 -> grid(-row=>1,-column=>0,-columnspan=>1);
    $but2 -> grid(-row=>1,-column=>1,-columnspan=>1);
    $but3 -> grid(-row=>1,-column=>2,-columnspan=>1);
    $but4 -> grid(-row=>1,-column=>3,-columnspan=>1);
    $but5 -> grid(-row=>1,-column=>4,-columnspan=>1);
    $but6 -> grid(-row=>1,-column=>5,-columnspan=>1);
    $txt -> grid(-row=>1,-column=>1);
    $srl_y -> grid(-row=>1,-column=>5,-sticky=>"ns");
    $srl_x -> grid(-row=>2,-column=>1,-sticky=>"ew");
    
    #文本区域 从第2行顶格开始长度为6
    $textarea -> grid(-row=>2,-column=>0,-columnspan=>6);
    MainLoop;
    
    
    
    sub push_button1 {
    # system("cls");
    my $dbName = 'june';  
    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 table_name,tablespace_name,status from user_tables};  
     
    
    my ($table_name, $tablespace_name, $status);  
    my $selStmt = $dbh->prepare($hostSql);  
    $selStmt->bind_columns(undef, $table_name, $tablespace_name, $status);  
    $selStmt->execute();  
    while( $selStmt->fetch() ){  
    	#print "$table_name		   $tablespace_name		$status
    ";  
    $txt -> insert("end","$table_name	$tablespace_name	$status"."
    ");
    }  
    $selStmt->finish;  
    $dbh->disconnect; 
    }
    


    
                                        
    
  • 相关阅读:
    文件查找和压缩
    shell脚本编程基础
    [模板]数据生成与对拍
    Codeforces Round #746 (Div. 2)
    Codeforces Round #712 (Div. 2)
    Codeforces Round #715 (Div. 2)
    Codeforces Round #752 (Div. 2)
    提高模拟赛Day8T3树上跑步
    提高模拟赛Day8T2最大匹配
    提高模拟赛Day8T1求中位数
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13351921.html
Copyright © 2020-2023  润新知