1.pack is the most commonly used
2.The grid geometry manager has been improved greatly with the release of Tk 8.0 and subsequent porting to Perl.
3.The place geometry manager is the most tedious to use,because you have to determine exact coordinates (relative or absolute) for every single widget.
4.the form geometry manager is like a combination of pack and place .
pack参数
- -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
-
- Methods Associated with pack:
- Unpacking a widget:
$widget->packForget( );
- Retrieving pack information:
@list = $widget->packInfo( ); - disabling and enabling automatic resizing:
$widget->packPropagate(0);
- Listing widgets:
@list = $parentwidget->packSlaves( );
tk之font:
- Family
- The actual name of the font,e.g.,'Courier','Times',and so on.
- Size
- The size of the font in points. The larger the size,the larger the text displayed on the screen. A point is 1/72 of an inch. Negative values are interpreted as pixels.
- Weight
- Determines if the font is shown boldor not. The value 'normal' means it is not shown bold,and 'bold' makes the font thicker.
- Slant
- Shows straight up and down if 'roman' is used,and slanted if 'italic' is used.
- Underline
- If the value used with -underline is true,the text will be underlined. If false,the text will not be underlined.
- Overstrike
- If true,a line will be drawn through the center of the text.
If you are used to working with fonts on a Unix system,you are probably
font使用:
(1)创建font:
$code_font = $mw->fontCreate('code',-family => 'courier',
然后进行引用:
$mw->Button(-text => "Show Code",-font => 'code');
$mw->Button(-text => "Show Code2",-font => $code_font);
-size => 12);
(2)$mw->fontConfigure($code_font,-family => 'Verdana');
-font => ['courier','14','bold'] # The same thing,but more verbose: -font => [-family => 'courier',-size => '14',-weight => 'bold']