[IronPython] How to get Keyboard Input

Andrew Evans evans.d.andrew at gmail.com
Fri Aug 6 00:09:43 CEST 2010


Um what?

This is just something I do as a hobby :-P

On Thu, Aug 5, 2010 at 3:06 PM, Duong Vu <duong.v at gmail.com> wrote:

> Hi Andrew,
>
> What the pay range on this? Unless its insane, I think I'll pass. I
> would prefer to stay around LA.
>
> Sent from my iPhone
>
> On Aug 5, 2010, at 2:54 PM, Andrew Evans <evans.d.andrew at gmail.com> wrote:
>
> > Hello I am trying to use the up down left right arrow keys to move an
> object
> >
> > How ever it does not seem to work and I receive no error messages any
> ideas?
> >
> > from System.Windows.Input import KeyEventHandler
> >
> > velocity = 10
> >
> > class Gui():
> >     def __init__(self):
> >         KeyEventHandler(self.KeyDown_Control)
> > ................................
> >
> >
> >     def KeyDown_Control(self, s, e):
> >         if e.Key == Key.Right:
> >             self.canvas.SetLeft(self.ship, self.canvas.GetLeft(self.ship)
> + velocity)
> >         elif e.Key == Key.Left:
> >             self.canvas.SetLeft(self.ship, self.canvas.GetLeft(self.ship)
> - velocity)
> >         elif e.Key == Key.Up:
> >             self.canvas.SetTop(self.ship, self.canvas.GetTop(self.ship) -
> velocity)
> >         elif e.Key == Key.Down:
> >             self.canvas.SetTop(self.ship, self.canvas.GetTop(self.ship) +
> velocity)
> >
> > Cheers
> >
> > and thank you
> >
> > Andrew
> > _______________________________________________
> > Users mailing list
> > Users at lists.ironpython.com
> > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100805/d1c9c7f6/attachment.html>


More information about the Ironpython-users mailing list