如何在我的自定义小部件中实现gtkorientable
-
21-12-2019 - |
题
如何在我的自定义窗口小部件中实现gtkorientable,到目前为止我所做的是:
class MyOwnWidget(Gtk.Orientable, Gtk.DrawingArea):
...
.
当我运行gtk抛出:
/usr/lib/python3.4/site-packages/gi/types.py:194: Warning: Object class gtkmeter+GtkMeter doesn't implement property 'orientation' from interface 'GtkOrientable'
_gobject.type_register(cls, namespace.get('__gtype_name__'))
.
这是实现gtkorientable的正确步骤?
解决方案
gtkorientable需要在实现此接口的类上存在“方向”属性。要在Python中执行此操作,您可以使用gobject.property:
from gi.repository import GObject
from gi.repository import Gtk
class MyOwnWidget(Gtk.DrawingArea, Gtk.Orientable):
orientation = GObject.Property(type=Gtk.Orientation, default=Gtk.Orientation.VERTICAL)
.
还记录继承的顺序,因为gtk.orientable是一个接口,它应该在你是子类的具体课程之后。也可以看看: https://developer.gnome.org/gtk3/stable/gtk3-orientable.html
不隶属于 StackOverflow