且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将任意小部件放入gtk.Menu?

更新时间:2023-01-27 15:14:27

PyGTK文档引用: p>

Quoting from the PyGTK documentation:


gtk.MenuItem及其派生的
小部件子类是菜单中唯一有效的
子元素。

The gtk.MenuItem and its derived widget subclasses are the only valid children of menus.

所以答案是:你不能。但是:
$ b

So the answer is: You can't. But:


作为gtk.MenuItem是gtk.Bin的子类,它可以容纳任何有效的子部件。

As a gtk.MenuItem is a subclass of gtk.Bin it can hold any valid child widget.

如果您创建没有标签的MenuItem:

If you create a MenuItem without a label:

item = gtk.MenuItem()

你可以添加大多数 gtk.Widget 子类为项目。

you can add most gtk.Widget subclasses as a child to item.