# Ironpython GUI: import wpf

**URL:** https://www.finalbuilder.com/forums/t/ironpython-gui-import-wpf/1792
**Category:** Discussion
**Created:** [June 27, 2011, 5:27am UTC](https://www.finalbuilder.com/forums/t/ironpython-gui-import-wpf/1792 "2011-06-27T05:27:04Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [June 27, 2011, 5:27am UTC](https://www.finalbuilder.com/forums/t/ironpython-gui-import-wpf/1792/1 "2011-06-27T05:27:04Z")

</div>

&nbsp;Hi,

&nbsp;

So I was trying to call a wpf xaml from python script in FB,

But &nbsp;as I tried "import wpf",

an error is raised: "ImportError: No module named wpf"

(But modules such as System, clr import perfectly fine)

Is there anyway to make wpf module works with FB?

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [June 27, 2011, 5:45am UTC](https://www.finalbuilder.com/forums/t/ironpython-gui-import-wpf/1792/2 "2011-06-27T05:45:51Z")

</div>

Hi,   
 Can you import the wpf module using the IronPython console?   
  
 Cheers,   
  
 Ben

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [June 27, 2011, 7:04am UTC](https://www.finalbuilder.com/forums/t/ironpython-gui-import-wpf/1792/3 "2011-06-27T07:04:18Z")

</div>

&nbsp;Thanks for the quick reply.

Yes, I can import wpf using IronPython console.

I've tried setting Python Library Directory to:

&nbsp; &nbsp; - ...\IronPython2.7\

&nbsp; &nbsp; - ...\IronPython2.7\DLLs\

&nbsp; &nbsp; - ...\IronPython2.7\Lib\

with no luck.

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [June 27, 2011, 7:20am UTC](https://www.finalbuilder.com/forums/t/ironpython-gui-import-wpf/1792/4 "2011-06-27T07:20:08Z")

</div>

Hi,   
 Can you post your import code? I can’t seem to find a module named wpf referenced anywhere, and in the examples I’m finding online (eg [http://ericgazoni.wordpress.com/2010/05/03/ironpython-wpf/](http://ericgazoni.wordpress.com/2010/05/03/ironpython-wpf/)) people are adding their WPF as such:   
  
 [code]import clrclr.AddReferenceByPartialName(“PresentationCore”)clr.AddReferenceByPartialName(“PresentationFramework”)[/code]   
  
 That code works fine for me in FinalBuilder.   
  
 Cheers,   
  
 Ben

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [June 27, 2011, 7:59am UTC](https://www.finalbuilder.com/forums/t/ironpython-gui-import-wpf/1792/5 "2011-06-27T07:59:37Z")

</div>

&nbsp;Edit: OMG, I think I messed up with the post format &nbsp;I'm editing it

Hi,

I'm sorry on my lack of information.

The code is as follows (this is actually auto generated by Visual Studio 2010 with IronPython installed) :&nbsp;

[code]

import wpfimport Systemfrom System.Windows import Application, Windowclass MyWindow(Window): def \_\_init\_\_(self): wpf.LoadComponent(self, 'WpfApplication1.xaml') def Button\_Click(self, sender, e): passApplication().Run(MyWindow())

[/code]

In IronPython console, calling wpf returns that it is a built-in function :&nbsp;

[code]

\>\>\> import wpf\>\>\> wpf

[/code]

I'll try using clr and see what comes up.

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [June 27, 2011, 8:07am UTC](https://www.finalbuilder.com/forums/t/ironpython-gui-import-wpf/1792/6 "2011-06-27T08:07:24Z")

</div>

In both IronPython 2.6 and 2.7 (alpha) I get ‘No module named wpf’, and when I create a new IP/WPF solution in VS2010 I get:   
  
 [code]import clrclr.AddReference(‘PresentationFramework’) [/code]   
  
 My guess (and I’ll try to confirm) is that the wpf module has been added to IP 2.7 fairly recently. FinalBuilder uses IP2.6, so that may explain the problem.   
  
 Cheers,   
  
 Ben

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [June 27, 2011, 8:17am UTC](https://www.finalbuilder.com/forums/t/ironpython-gui-import-wpf/1792/7 "2011-06-27T08:17:42Z")

</div>

Hi,   
 The following link:   
 [http://ironpython.codeplex.com/releases/view/54498](http://ironpython.codeplex.com/releases/view/54498)

> This version of IronPython Tools includes a number of bug fixes as improved WPF designer support. The designer fully supports XAML and WPF including data binding to Python classes dynamically.

   
  
 So I guess yeah, the module might be just added recently.   
 It’ll be great if FinalBuilder can support this, though.   
 Meanwhile, I’ll try using the clr way.   
  
 Thanks for your time : )
