如何在 PyGTK 组合框中添加分隔符?

发布于 2024-08-28 02:41:39 字数 171 浏览 6 评论 0原文

我正在使用 gtk.combo_box_new_text() 来制作组合框列表,这使用 gtk.ListStore 仅存储字符串,因此有某种方法可以在项目之间添加分隔符而不使用复杂的 gtk.TreeModel 吗?

如果这是不可能的,那么使用 gtk.TreeModel 能够连续添加小部件的最简单方法是什么?

I'm using gtk.combo_box_new_text() to make combobox list, this uses a gtk.ListStore to store only strings, so there are some way to add a separator between items without use a complex gtk.TreeModel?

If this is not possible, what is the simplest way to use a gtk.TreeModel to able secuential widget addition?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

獨角戲 2024-09-04 02:41:39

我认为您应该使用 ComboBox.set_row_separator_func 来设置分隔符函数,您可以在其中确定列表中的哪些项目将是分隔符。由于 ListStore 实现了 TreeModel 接口,因此在您的情况下使用它应该没有问题。

PS:GTK 中没有什么是容易的:)

I think that you should use ComboBox.set_row_separator_func to set a separator function where you would determine which items of your list will be separators. Since ListStore implements TreeModel interface, you should have no problem simply using it in your case.

P.S.: nothing is easy in GTK :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文