使用组合框值

时间:2011-04-08 08:19:30

标签: pygtk

感谢S. Lott的快速回复。

我的问题是关于第一篇文章中的这个链接:

Python GTK adding signal to a combo box

我想在主窗口GUI

中重用组合的更改值

这种方式有可能,怎么样?

感谢您的一些解释

祝你好运

1 个答案:

答案 0 :(得分:2)

如果您将ComboBox与自己的自定义模型一起使用,则始终可以获取所选项目的数据:

index = combo.get_active()
model = combo.get_model()
item = model[index]
print item[0] ## , item[1], ...

但如果您使用的是文本组合框(使用gtk.combo_box_new_text()创建),则更易于使用:

item_text = combo.get_active_text()
print item_text
相关问题