繁体   English   中英

如何在pygtk中的消息中添加组合框?

[英]How do I add a combobox to a message in pygtk?

如何将组合框添加到弹出窗口并返回用户选择的结果? 我正在尝试从我看到的其他示例中改编代码,因为gtk文档并不十分清楚。 我的情况与以下情况类似,但进展并不很快(或者说很慢,更准确地说)。

        message = gtk.Dialog(title=None,
                             parent=None,
                             flags=0,
                             buttons=None)

        combo = gtk.combo_box_new_text()
        for key in self.MyBom.potential_keywords:
            combo.append_text(key)
        combo.set_active(0)

        cell = gtk.CellRendererText()
        combo.pack_start(cell, True)
        combo.add_attribute(cell, 'text', 0)

        response = 0

        message.add_action_widget(combo, response)
        response = message.run()

add_action_widget()需要一个可激活的小部件。 您可以尝试使用get_content_area() (一个VBox)并将组合框包装到其中。 然后,您可以连接“已更改”信号以破坏对话框。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM