[IronPython] Trying (unsuccessfully) to subclass Gtk.Widget class

Michael Welch michaelgwelch at gmail.com
Fri Sep 15 20:19:34 CEST 2006


I'm running IPython 1.0 on mono on Linux. I'm importing the gtk-sharp
dll and I want to subclass the Gtk.Widget class

Here is my script:

from Gtk import *
from Gnome import *


class Table:
class Sheet(Widget):
 def __init__(self, table):

Here is my ipy session where I try to use Sheet

IronPython 1.0.2432 on .NET 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
>>> import sheet
>>> from sheet import *
>>> t = Table()
>>> s = Sheet(t)
Traceback (most recent call last):
TypeError: no overloads of Sheet could match (type, Table)
  Sheet(type, IntPtr)
  Sheet(type, GType)


It tells me it can't find an appropriate overload for Sheet and then
gives me what looks like the only two possible candidates. However,
the candidates it lists looks like they are from the parent class
Widget. Does IronPython hava a constraint that the __init__ method
must take the same parameters as the parent class? Here is the list of
constructors for Widget:

If I remove the parameter from __init__ it works. I've tested this
scenario with made up classes and it works. CPython documentation
seems to indicate that a child class can have different parameters on
its __init__method then the parent class. Any help? Is there something
wrong with the gt-sharp library (I don't think so, as I could write a
C# app that did this same thing and it worked).

I'm convinced this must be user-error and I'm just not seeing the problem


More information about the Ironpython-users mailing list