【问题标题】:GtkToolbar: How to add Toolitem to toolbar using PyGObjectGtkToolbar:如何使用 PyGObject 将 Toolitem 添加到工具栏
【发布时间】:2014-07-04 02:19:00
【问题描述】:

如何使用 PyGObject 向 GtkToolbar 添加图标?

我可以毫无问题地创建工具栏和图标:

    self.toolbar = Gtk.Toolbar()
    self.item = Gtk.ToolItem()

但是将项目添加到工具栏似乎不像这样(在 PyGTK 文档中找到):

    self.toolbar.Container.add(self.item)

【问题讨论】:

    标签: gtk3 pygobject


    【解决方案1】:

    解决方案其实很简单:

        self.button = Gtk.ToolButton(Gtk.STOCK_ABOUT)
        self.toolbar.insert(self.button, 0)
    

    用户按钮而不是项目,然后从此列表中选择一个图标:http://python-gtk-3-tutorial.readthedocs.org/en/latest/stock.html

    然后将 .inset 与对象和位置一起使用(在本例中为 0,表示工具栏中的第一项)。

    【讨论】:

      猜你喜欢
      • 2011-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多