[IronPython] Having Issues With KeyUp Event

Dino Viehland dinov at microsoft.com
Fri Sep 18 18:18:31 CEST 2009


You're probably missing a reference to System.Windows.Input, doing:

clr.AddReference('System.Windows.Input')

will probably make it work.

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nick Hird
Sent: Friday, September 18, 2009 9:05 AM
To: users at lists.ironpython.com
Subject: [IronPython] Having Issues With KeyUp Event

I am new to IronPython and kinda new to Python but i decided to look
around and find some samples and decided to build something using WPF
inside IronPython. I am trying to add a KeyUp event to a TextBox and
when i enter the texttbox and press any key i get an error. Now in WPF
this code works just fine but i cannot get the if statement correct
for some reason. Any Ideas?
Thanks!

[CODE]
def address_keyup(sender, args):
    if args.Key == System.Windows.Input.Key.Enter:
        LoadWebsite(address.Text)

[ERROR]
Traceback (most recent call last):
  File "IronPythonWPFWebBrowser.py", line 118, in IronPythonWPFWebBrowser.py
  File "PresentationFramework", line unknown, in Run
  File "PresentationFramework", line unknown, in RunInternal
  File "PresentationFramework", line unknown, in RunDispatcher
  File "WindowsBase", line unknown, in Run
  File "WindowsBase", line unknown, in PushFrame
  File "WindowsBase", line unknown, in PushFrameImpl
  File "WindowsBase", line unknown, in RaiseThreadMessage
  File "PresentationCore", line unknown, in OnPreprocessMessage
  File "PresentationCore", line unknown, in OnPreprocessMessageThunk
  File "WindowsBase", line unknown, in Invoke
  File "WindowsBase", line unknown, in InvokeImpl
  File "WindowsBase", line unknown, in WrappedInvoke
  File "WindowsBase", line unknown, in TryCatchWhen
  File "WindowsBase", line unknown, in InternalRealCall
  File "PresentationCore", line unknown, in OnPreprocessMessage
  File "PresentationCore", line unknown, in CriticalTranslateAccelerator
  File "PresentationCore", line unknown, in ProcessKeyAction
  File "PresentationCore", line unknown, in ReportInput
  File "PresentationCore", line unknown, in ReportInput
  File "PresentationCore", line unknown, in ProcessInput
  File "PresentationCore", line unknown, in ProcessStagingArea
  File "PresentationCore", line unknown, in RaiseEvent
  File "PresentationCore", line unknown, in RaiseEventImpl
  File "PresentationCore", line unknown, in InvokeHandlersImpl
  File "PresentationCore", line unknown, in InvokeHandler
  File "PresentationCore", line unknown, in InvokeHandler
  File "PresentationCore", line unknown, in InvokeEventHandler
  File "", line unknown, in System.Void(Object, KeyEventArgs)
  File "IronPythonWPFWebBrowser.py", line 99, in address_keyup
AttributeError: 'namespace#' object has no attribute 'Key'

-- 
--Nick
_______________________________________________
Users mailing list
Users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com



More information about the Ironpython-users mailing list