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


    
                                        
    
  • 相关阅读:
    linux里source、sh、bash、./有什么区别
    grafna如何用新的dashbord覆盖旧的dashbord
    selenium.webdriver获取结果转为json格式
    利用Python读取和修改Excel文件(包括xls文件和xlsx文件)——基于xlrd、xlwt和openpyxl模块
    python多线程实现ping多个ip
    Kubernetes 从懵圈到熟练 – 集群网络详解(转)
    kubectl 自动补全
    跨域资源共享 CORS 详解
    serializers--嵌套关系作为字段来表示
    Vue结合后端DjangoFramework的在线生鲜超市(前后端分离)【django2.2+xadmin+ueditor】
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13351921.html
Copyright © 2011-2022 走看看