• pack 布局参数


    #!/usr/bin/perl -w
    use Tk;
    use Tk::BrowseEntry;
    use strict;
    ## (-title => 'Font Viewer' ) 标题,窗口的标题
    my $mw = MainWindow->new(-title => 'xxoo');
    
    ##框体布局在顶部
    my $f = $mw->Frame->pack(-side => 'top');
    
    my $family = 'Courier';
    
    ##变量的引用,调用函数 布局水平 布局在左边
    my $be = $f->BrowseEntry(-label => 'Family:', -variable => $family,
    -browsecmd => &apply_font)->pack(-fill => 'x', -side => 'left');
    
    
    $be->insert('end', sort $mw->fontFamilies);
    
    
    my $size = 24;
    my $bentry = $f->BrowseEntry(-label => 'Size:', -variable => $size,
    -browsecmd => &apply_font)->pack(-side => 'left');
    
    $bentry->insert('end', (3 .. 32));
    my $weight = 'normal';
    $f->Checkbutton(-onvalue => 'bold', -offvalue => 'normal',
    -text => 'Weight', -variable => $weight,
    -command => &apply_font)->pack(-side => 'left');
    
    my $slant = 'roman';
    $f->Checkbutton(-onvalue => 'italic', -offvalue => 'roman',
    -text => 'Slant', -variable => $slant,
    -command => &apply_font)->pack(-side => 'left');
    
    my $underline = 0;
    $f->Checkbutton(-text => 'Underline', -variable => $underline,
    -command => &apply_font)->pack(-side => 'left');
    
    
    
    my $overstrike = 0;
    $f->Checkbutton(-text => 'Overstrike', -variable => $overstrike,
    -command => &apply_font)->pack(-side => 'left');
    
    my $stext = 'Sample Text';
    my $sample = $mw->Entry(-textvariable => $stext)->pack(-fill => 'x');
    
    my $sample1 = $mw->Entry(-textvariable => $stext)->pack(-fill => 'x',-side => 'left');
    
    &apply_font;
    MainLoop;
    sub apply_font {
    # Specify all options for font in an anonymous array
    $sample->configure(-font =>
    [-family => $family,
    -size => $size,
    -weight => $weight,
    -slant => $slant,
    -underline => $underline,
    -overstrike => $overstrike]);
    }
    
    
    
    Options for pack
    
    This list shows all the options available when you call pack (the default values are shown in 
    
    bold):
    下面列出在pcak使用时的所有选项(默认值用粗体表示)
    
    -side => 'left' | 'right' | 'top' | 'bottom
    Puts the widget against the specified side of the window or Frame
    设定部件窗口或框架的位置
    
    -fill => 'none' | 'x' | 'y'| 'both'
    Causes the widget to fill the allocation rectangle in the specified direction
    设定部件延那个方向填充
    
    -expand => 1 | 0
    Causes the allocation rectangle to fill the remaining space available in the window or Frame
    在窗口或框架中是否填补剩余的空间
    -anchor => 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'nw' | 'center'
    
    Anchors the widget inside the allocation rectangle
    设定部件的方向
    
    -after => $otherwidget
    Puts $widget after $otherwidget in packing order
    设定部件放置在哪个部件之前
    
    -before => $otherwidget
    Puts $widget before $otherwidget in packing order
    设定部件放置在哪个部件之前
    
    -in => $otherwindow
    Packs $widget inside of $otherwindow rather than the parent of $widget, which is the default
    设定部件放置在哪个窗口中
    
    -ipadx => amount
    Increases the size of the widget horizontally by amount
    增加部件横向的大小
    
    -ipady => amount
    Increases the size of the widget vertically by amount
    增加部件纵向的大小
    
    
    -padx => amount
    Places padding on the left and right of the widget
    设定部件的左右两边增加额外的空间
    
    -pady => amount
    Places padding on the top and bottom of the widget
    设定部件的上下两边增加额外的空间
    
    
    
    -width=>10  宽度
    
    -height=>40

  • 相关阅读:
    php程序去除文件 bom头
    类继承接口后,实现接口的方法
    virtual和abstract的使用场景分别是什么?待更新。
    get请求和post请求的总结
    ES6新语法,持续更新
    display:flex中的不懂的问题,待处理
    css相邻兄弟选择器(+),伪类(:hover),伪元素(::after)
    HTML中的input的type类型
    命令行打开程序的集合
    sqlserver 常用的语句
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13351903.html
Copyright © 2020-2023  润新知