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. 如果将插字游标上下移动或者调整来加视窗的大小所呼叫的程序
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。