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.
Perl 列表框
最新推荐文章于 2020-01-15 21:48:23 发布
本文介绍了Perl中创建和配置Listbox的方法,包括设置背景颜色、边框宽度、选择模式等参数,并展示了如何绑定事件来改变列表框背景颜色。此外,还详细说明了Listbox的各种属性,如font、foreground、height等,以及如何使用scrollbar进行滚动操作。
摘要由CSDN通过智能技术生成