What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Python help

Python help
Author: Message:
Chancer
Senior Member
****

Avatar

Posts: 648
Reputation: 7
35 / Male / Flag
Joined: May 2005
Status: Away
O.P. Python help
I'm coding a program that sends some data via serial when a key is pressed:

Python code:
from Tkinter import *
from serial import Serial

Arduino = Serial(3)
Arduino.baudrate = 115200

root = Tk()

def Acelerate (event):
    Arduino.write ("Ax")
def Reverse (event):
    Arduino.write ("Rx")
def Right (event):
    Arduino.write ("xD")
def Left (event):
    Arduino.write ("xE")

root.bind ('<Up>', Acelerate)
root.bind ('<Down>', Reverse)
root.bind ('<Right>', Right)
root.bind ('<Left>', Left)
root.mainloop()

It's working pretty fine. You press Up in you keyboard, it sends data which makes an RC car move forward. You press Down, it moves backward. When you press Right or Left, it turns its wheels to that side.

Now I need to do this: when I press, for example, Up and Right at the same time, I need to send "AD" (stupid math, "Ax + xD"), and analog for other combinations.
How can I do this multi-key binding?

I saw some examples with modifier keys, like "root.bind ('<Control-A>', asd)", but this combination <'Key1-Key2'> seems to work only with these modifiers (Control, Alt, Shift, etc).

So, do you think it's possible?

This post was edited on 09-26-2009 at 10:43 PM by Chancer.
09-14-2009 01:47 AM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Python help - by Chancer on 09-14-2009 at 01:47 AM
RE: Python help - by Ezra on 09-14-2009 at 05:23 PM
RE: Python help - by Chancer on 09-14-2009 at 08:55 PM
RE: Python help - by Jarrod on 09-15-2009 at 08:11 AM
RE: Python help - by Chancer on 09-15-2009 at 08:45 PM
RE: Python help - by matty on 09-16-2009 at 12:36 PM
RE: Python help - by Chancer on 09-16-2009 at 05:55 PM
RE: Python help, Solution :) - by Jarrod on 09-20-2009 at 01:33 PM
RE: Python help - by Chancer on 09-20-2009 at 03:26 PM
RE: Python help - by Jarrod on 09-20-2009 at 09:40 PM
RE: Python help - by Chancer on 09-20-2009 at 10:05 PM
RE: Python help - by Jarrod on 09-20-2009 at 10:08 PM
RE: Python help - by Chancer on 09-21-2009 at 01:06 AM
RE: Python help - by Jarrod on 09-21-2009 at 01:23 AM
RE: Python help - by Chancer on 09-26-2009 at 11:20 PM
RE: Python help - by Jarrod on 09-27-2009 at 09:35 AM
RE: Python help - by Chancer on 09-27-2009 at 02:39 PM
RE: Python help - by Jarrod on 09-27-2009 at 09:12 PM
RE: Python help - by Chancer on 09-27-2009 at 10:47 PM
RE: Python help - by Chancer on 10-04-2009 at 04:05 AM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On