Creating a command that can be used anytime

This is the place for queries that don't fit in any of the other categories.

Creating a command that can be used anytime

Postby manbearpig69 » Fri Jul 19, 2013 9:17 am

im pretty new to python and just want some help with this:
just wondering if i could make it so that while running the program a user can type a command in the console at ANYTIME not just on say on raw inputs...
so say while the program is running if a user types /menu it will launch a defined subprogram instead of only being able to type /menu on raw inputs which would be alot of work on my end making sure every raw_input allows /menu as a response...thanks
manbearpig69
 
Posts: 2
Joined: Fri Jul 19, 2013 9:09 am

Re: Creating a command that can be used anytime

Postby metulburr » Fri Jul 19, 2013 9:36 am

i am going to assume you mean typing input on the fly as opposed to typing input and hitting enter.

just wondering if i could make it so that while running the program a user can type a command in the console at ANYTIME not just on say on raw inputs...

You could use a GUI library as all of them have a source to take input on the fly), For terminal use, there are the modules, termios for linux and msvcrt for windows. You can google them to get some code snippets of how to handle them.

so say while the program is running if a user types /menu it will launch a defined subprogram instead of only being able to type /menu on raw inputs which would be alot of work on my end making sure every raw_input allows /menu as a response...thanks

It would be lot less work to use raw_input()/input() than it would be to create/modify/use other libraries and make your own functions to accomodate termios folr example to catch user input on the fly. Its a lot more simpler to use input and have the user hit enter.
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1470
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY


Return to General Coding Help

Who is online

Users browsing this forum: Google [Bot] and 1 guest