2014-06-04 63 views
0

我怎么能在我的自定义窗口小部件实现GtkOrientable,什么我迄今所做的是:如何在我的自定义窗口小部件实现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的正确步骤?

回答

2

GtkOrientable要求“orientation”属性存在于实现此接口的类上。在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

相关问题