Overriding Virtual Methods In Pygobject
I'm trying to implement the Heigh-for-width Geometry Management in GTK with Python for my custom Widget. My widget is a subclass from Gtk.DrawingArea and draws some parts of an Ima
Solution 1:
You have to name the methods like do_virtual_method
:
from gi.repository import Gtk
classPatch(Gtk.DrawingArea):
def__init__(self):
super(Patch,self).__init__()
defdo_get_preferred_width(self):
print("test")
return100, 100defdo_get_preferred_height(self):
print("test")
return100, 100
win = Gtk.Window()
win.add(Patch())
win.connect('destroy', Gtk.main_quit)
win.show_all()
Gtk.main()
Note that you also have to return the values that the virtual method requires you to return, otherwise you'll get a cryptic error.
Post a Comment for "Overriding Virtual Methods In Pygobject"