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!

Recommended Answers

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 …
Jump to Post

All 2 Replies

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()

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.