[Ironpython-users] FW: IronPython WPF application
Jackie Sproat
JackieSproat at smarttech.com
Mon Dec 10 18:03:10 CET 2012
I am simply trying to get the handle to a WPF window, but it doesn't seem to be working.
I am as new to WPF as I am to IronPython so please forgive me :)
>From what I have read I believe the handle is not getting set in __init__ because it is only available at run_time(?)
Therefore, have to add Loaded="Window_Loaded" in MyWindow.xaml so that handle is guaranteed to be set after window is loaded(?)
However, this requires a routed event handler which, I know nothing about but I do know the line:
((MyWindow)(target)).Loaded += System.Windows.RoutedEventHandler(this.Window_Loaded);
Works in C#, not sure what the equivalent line would be in IronPython?
Please help, I simply want to run MyWindow and get a handle to it!
Here is a snippet of my code:
class MyWindow(Window):
def __init__(self):
wpf.LoadComponent(self, 'WpfApp_Test.xaml')
self.hWnd = WindowInteropHelper(self).Handle #self.hWnd is not getting set
dir(self.hWnd)
def Window_Loaded(self):
self.hWnd = WindowInteropHelper(self).Handle #never gets called
if __name__ == '__main__':
Application().Run(MyWindow())
#((MyWindow)(target)).Loaded += System.Windows.RoutedEventHandler(MyWindow().Window_Loaded)
Actual, WPF IronPython app (VS2010) is contained in .zip folder attached (just need to rename .zzz to .zip and decompress)
Cheers,
Jackie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20121210/cc1dfacf/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: WpfApp_Test.zzz
Type: application/octet-stream
Size: 5619 bytes
Desc: WpfApp_Test.zzz
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20121210/cc1dfacf/attachment.obj>
More information about the Ironpython-users
mailing list