• 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

  • 相关阅读:
    我觉得总结的不错的entityFramework
    vs2013引入com组件后,发布时如何提取出dll文件
    win10创建扩展分区
    web.config配置
    mysql时间增加一年
    json介绍
    phpcms列表分页ajax加载更多
    phpcms批量更新内容页只更新一点就返回问题
    phpcms不能批量更新栏目页和内容页
    iis设置默认文档,提示web.config配置xml格式不正确
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13351903.html
Copyright © 2020-2023  润新知