Discuss While with responses to keyboard in the Python Programming forum on Dev Shed. While with responses to keyboard Python Programming forum discussing coding techniques, tips and tricks, and Zope related information. Python was designed from the ground up to be a completely object-oriented programming language.
Posts: 5
Time spent in forums: 56 m 7 sec
Reputation Power: 0
While with responses to keyboard
Hi all,
I'm a rather inexperienced python programmer. I'm looking for some construct that will start an indefinite loop (eg. while True or something similar) and the program will respond to the keyboard events. Something rather simple: q - get out of the loop and quit, 1 - do something, 2 - do something.
Code:
def some_function:
pass
def other_function:
pass
my loop:
if key == "1":
some_function
else if key == "2":
other_function
Thanking you all.
etc.
I think it is called event driven programming. I can't find anything relevant. It's all about Twisted which looks like has a lot of opponents. Could you recommend something? I don't need/want GUI and I'd like something different than "input" where you need to press enter after the user input.
Posts: 5
Time spent in forums: 56 m 7 sec
Reputation Power: 0
One more question. I'm trying to get the centre of a window so that I can position, eg. a title right in the middle regardless of the size of my terminal window.