WPF generated classes - error "name 'accepts' not defined" in InitializeComponent

Jan 29, 2008 at 12:24 PM

I'm trying to build a WPF application using iron python studio. I followed the steps in the readme.html file, and now when I add a x:Class declaration to my Window1.xaml I get a Window1.g.py file being generated and included in my built assembly (so far so good). Since (AFAIK) python doesn't have the concept of partial classes I'm declaring a class (lets say Foo) which inherits from the class that I specify in the xaml file (lets say Window1Base), and which gets put in the generated .py file. I add an imports statement to bring in the generated file and declare my class like this (sans formatting it would seem):

class WpfApplication1: # namespace
from clr import *
# a couple more imports go here
import Window1_g

class Foo(Window1_g.Window1Base):
def _init_(self):
print 'hello'

At run-time I get an error saying "name 'accepts' not defined" on the InitializeCompoent method of my generated class (presumably referring to the accpets attribute on that method - see snippet below). Looking at the call stack the InitializeComponent method seems to be getting called via the imports statement! The InitializeComponent method declaration looks like this, and the class itself seems to have all the correct imports statements:

def InitializeComponent(self):

My python is really rusty, but this just seems weird. Can anyone explain why this is happening and/or how to work around it????
Jul 7, 2008 at 11:27 PM

Did you solve this problem?

I solved this event typing:  "from clr import *"  instead of "import clr" on the top of the form.py file.