带有嵌入小部件的 Perl Tk 列表框?
有谁知道 Perl Tk 中是否有一种类型的列表框允许您在列表中包含一个小部件?例如,我需要一个多列列表框,其中其中一列包含用户可以选中或取消选中的 Checkbutton 小部件。
does anyone know if there is a type of listbox in Perl Tk that allows you to have a widget in the list? For example, I need a multi-column listbox with one of the columns containing a Checkbutton widget that the user can check or uncheck.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,标准列表框小部件仅支持一行字符串作为内容。
不要沮丧,因为我们可以轻松构建一个更强大的列表框,其中可以包含小部件!
这是我为程序编写的一些代码。结果如下图(我画的,所以直接从相关文档中拿来的)
提示:
- 我编写的代码是使用 Tcl::Tk 模块在 Perl 中编写的,因此您可以轻松地将其更改为 Perl/Tk
- 如图所示,6个小部件组成一个数组@item,6个@item数组组成一个数组@cur_items,您可以从@cur_items开始查找此列表中的任何小部件(因为您已经知道顺序)
- 我使用额外的框架来使这些小部件整齐,如果您只想组织两个小部件,可以忽略它们。(但我建议使用框架)
- 请忽略小部件的名称,例如 subsubwidget 或 subsubdate,编码人员在繁重的编程压力下很难给出好听的名称:)
As far as I know, standard listbox widget only supports one line of string as content.
Don't be frustrated, because we can build a more powerful listbox, which CAN contain widgets, easily!
Here are some codes I wrote for a program. And the result is like the pic shown below(I draw it, so I take it directly from the related document)
The TIPS:
- The code I wrote is in Perl using Tcl::Tk module, so you can easily change it into Perl/Tk
- As the pic shows, 6 widgets build up an array @item, and 6 @item arrays build up an array @cur_items, and you can start from @cur_items to find any widget in this list (as you have already known the sequence)
- I use additional frames to make these widgets in tidy, you can ignore them if you only want to organize two widgets.(But I suggest using frame)
- Please ignore the widget's name, like subsubwidget or subsubdate, it is hard for coders to give nice names under heavy programming pressure :)
Tk::HList 可能就是您正在寻找的。请参阅:
http://www.perltk .org/index.php?option=com_content&task=view&id=23&Itemid=28
Tk::HList might be what you're looking for. See:
http://www.perltk.org/index.php?option=com_content&task=view&id=23&Itemid=28