カスタムウィジェットで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