Perl/tk之font

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:
  1. Unpacking a widget:
    $widget->packForget( );
  2. Retrieving pack information:
    @list = $widget->packInfo( );
  3. disabling and enabling automatic resizing:
    $widget->packPropagate(0);
  4. 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']

相关文章

1. 如何去重 #!/usr/bin/perl use strict; my %hash; while(...
最近写了一个perl脚本,实现的功能是将表格中其中两列的数据...
表的数据字典格式如下:如果手动写MySQL建表语句,确认麻烦,...
巡检类工作经常会出具日报,最近在原有日报的基础上又新增了...
在实际生产环境中,常常需要从后台日志中截取报文,报文的形...
最近写的一个perl程序,通过关键词匹配统计其出现的频率,让...