Cannot subclass objects with constructor arguments
- From: Kerrick Staley <mail kerrickstaley com>
- To: python-hackers-list gnome org
- Subject: Cannot subclass objects with constructor arguments
- Date: Sat, 11 Feb 2012 01:21:39 -0600
Hello,
I am having exactly the same issue (when trying to subclass Clutter.Box) as that described in this thread:
http://lists.clutter-project.org/pipermail/clutter-app-devel-list/2011-September/000742.html
Using the workaround that Martin described, I was able to get my code to function, but I'd like to know how to solve this problem in general. If a GObject's .new() method takes arguments, how can you supply those arguments in the __init__() method of a subclass? Here is my code:
from gi.repository import GObject, Clutter
class Editor(Clutter.Box):
def __init__(self):
# does not work: "TypeError: GObject.__init__() takes exactly 0 arguments (1 given)"
# super(Editor, self).__init__(Clutter.BinLayout.new(4,4))
# also does not work: "TypeError: __init__() takes exactly 1 argument (3 given)"
# GObject.__init__(self, Clutter.BinLayout.new(4,4))
# workaround
self.set_layout_manager(Clutter.BinLayout.new(4,4))
Thanks,
Kerrick Staley
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]