Perl 列表框

use Tk; 
my $mw = new MainWindow;
$lb = $mw->ListBox(-selectmode => "single")->pack( ); 
$lb->insert('end',qw/red yellow green blue grey/);
##绑定到左键<Button-1>
$lb->bind('<Button-1>',sub { $lb->configure(-background => $lb->get($lb->curselection( )) ); }); MainLoop

列表框参数:

-background => color
Sets the color of the area behind the text.
设置列表框的背景颜色
-borderwidth => amount
Sets the width of the edges of the widget. Default is 2.
设置列表框的边框宽度
-cursor => cursorname
Sets the cursor to display when the mouse is over the ListBox.
改变鼠标放在列表框上时鼠标的形状
-exportselection => 0 | 1
Determines if the current ListBox selection is made available for the X selection as well. If set to 1,prevents two ListBoxes from having selections at the same time.
设置选择构造,如果设置为了,防止两个listBox同时被选择
-font => fontname
Sets the font of any text displayed within the ListBox.
设置文字字型
-foreground => color
Sets the color of nonselected text displayed in the ListBox.
设置文字的颜色
-height => amount
Sets the height of the ListBox.
设置列表框的高度
-highlightbackground => color
Sets the color the highlight rectangle should be when the ListBox does not have the keyboard focus.
当列表框不是键盘输入焦点时,设定其颜色
-highlightcolor => color
Sets the color the highlight rectangle should be when the ListBox does have the keyboard focus.
当列表框为键盘输入焦点时,设定其颜色
-highlightthickness => amount
Sets the thickness of the highlight rectangle. Default is 2.
设定焦点的宽度,认值为2
-relief => 'flat'|'groove'|'raised'|'ridge'|'sunken'|'solid'
Sets the relief of the edges of the ListBox.
设定输入列表框3D效果
-selectbackground => color
Sets the color behind any selected text.
设定被选择文字背景颜色
-selectborderwidth => amount
Sets the width of the border around any selected text.
设定选取的外框的宽度
-selectforeground => color
Sets the color of the text in any selected items. 17
设定被选择文字的颜色
-selectmode => "single" | "browse" | "multiple" | "extended"
Affects how many items can be selected at once; also affects some key/mouse bindings for the ListBox (such as Shift-select).
设定选择模式
-setgrid => 0 | 1
Turns gridding off or on for the ListBox. Default is 0.
是否开启按网格倍数缩放窗口
-takefocus => 0 | 1 | undef
Determines whether the widget can have keyboard focus. 0 means never,1 means always,undef means dynamic decision.
庙宇是否让该列表框成为键盘输入焦点
-width => amount
Sets the width of the ListBox in characters. If amount is 0 or less,the ListBox is made as wide as the longest item.
设定列表框的宽度
-xscrollcommand => callback
Assigns a horizontal Scrollbar to widget.
如果将插字游标左右移动或者调整来加视窗的大小所呼叫的程序
-yscrollcommand => callback
Assigns a vertical Scrollbar to widget.
如果将插字游标上下移动或者调整来加视窗的大小所呼叫的程序

相关文章

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