[IronPython] IronPython+Gtk#+.NET?

Brian Parma freecode at cox.net
Sat Jul 18 06:34:50 CEST 2009

I've been trying to make a simple IronPython+Gtk# app that draws an 
image to the screen, and I'm having trouble getting it to run in windows 
(.NET).  It's pretty simple so I attached it at the end.

It runs fine in Mono on Ubuntu and Windows, but when I try to run it on 
windows using .NET I get the following error followed by a really long 

Marshaling expose_event signal
Exception in Gtk# callback delegate
  Note: Applications can use GLib.ExceptionManager.UnhandledException to 
the exception.
System.Reflection.TargetInvocationException: Exception has been thrown 
by the ta
rget of an invocation. ---> System.NotSupportedException: The invoked 
member is
not supported in a dynamic assembly.
   at System.Reflection.Emit.AssemblyBuilder.get_Location()
   at GLib.GType.LookupType(IntPtr typeid)
   at ...

I have the latest 'Gtk# for .NET' package from the Mono site, and I've 
tried with IP 2.0.1 and IP 2.6 Beta, they give the same results. 

I rewrote the program in C# and it works fine in .NET (without Mono), 
using #Develop IDE.

Is this possible?


import clr
import Gtk
import Gdk

class MyWindow(Gtk.Window):
    def __init__(self, title='Main Window'):
        Gtk.Window.__init__(self, title)
        self.pb = Gdk.Pixbuf('image.jpg').ScaleSimple(600,436, 
Gdk.InterpType.Bilinear )
        self.da = Gtk.DrawingArea()
        self.da.SetSizeRequest(self.pb.Width, self.pb.Height)
        self.Decorated = False
        self.DeleteEvent += self.delete_event       
        self.da.ExposeEvent += self.expose_event

    def expose_event(self, *args):
self.Style.BackgroundGC(self.State), self.pb, 0, 0, 0, 0,-1, -1, 
Gdk.RgbDither.None, 0, 0)
    def delete_event(self, *args):

if __name__ in ['__main__','Program']:
    mw = MyWindow('Test')

More information about the Ironpython-users mailing list