0

I have a very tough problem- how do you make an icon/character move across a console screen?

For example, if I press W,

+++++
++E++
+++++

Then I press D

+++++
+++E+
+++++

And I want it to be like the CHOICE command in CMD- Without requiring the user to press Enter. Any help would be appreciated! Thanks!

2
Contributors
2
Replies
4
Views
5 Years
Discussion Span
Last Post by 3e0jUn
0

You can use the Tkinter GUI toolkit that ships with Python:

# KeyLogger.py
# show a character key when pressed without using Enter key
# arrow keys are 'Up' 'Down' 'Left' 'Right' in event.keysym
# hide the Tkinter GUI window, only console shows

# Python3 change Tkinter to tkinter (now a package)
import Tkinter as tk

def key(event):
    if event.keysym == 'Escape':
        root.destroy()
    #print(event.char)   # test
    print(event.keysym)  # optional test

root = tk.Tk()
print("Press a key (Escape key to exit):")
root.bind_all('<Key>', key)
# don't show the tk window
root.withdraw()
root.mainloop()

Edited by HiHe: Python3

0

But how about the movement part? Like how do I apply this...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.