473,560 Members | 3,043 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re: How can I handle the char immediately after its input,without waiting an endline?


If you're doing this btw, you may want to look at
the curses module or urwid (3rd-party).


On Wed, Oct 22, 2008 at 9:17 PM, Lave <la*********@gm ail.comwrote:
Yes, it's what i want. Many thanks.

BTW,python-list 's reply is so quick. I love it. I like you all guys.

On 10/22/08, rishi pathak <ma************ *@gmail.comwrot e:
>The below piece of code should give you some understanding

import tty
import sys
tty.setraw(sys .stdin.fileno() )
print "Press x to exit"
while char != 'x' :
char = sys.stdin.read( 1)
print "You entered : ",char
# Your code here
On Wed, Oct 22, 2008 at 2:34 PM, Lave <la*********@gm ail.comwrote:
>>Hi, all.

I'm a new comer. So This question maybe sutpid.:)

I want to write something that handle every char immediately after its
input. Then tehe user don't need to type [RETURN] each time. How can I
do this?

Thanks in advance.


Rishi Pathak



-- "Problems are solved by method"
Oct 22 '08 #1
1 1527
Is there a way to do the opposite of tty.setraw afterwards to prevent
the terminal from not displaying any characters that are typed in? Of
course, this can be resolved by re-opening it, but thats not really
Oct 22 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: jagmeena | last post by:
Hello, I am sure this problem has been addressed before, however, I could'nt get a suitable solution to my problem. Hence I am posting here. Thanks a lot for all your help. The code I have is typedef struct Rec { unsigned char msg; unsigned long len;
by: Sathyaish | last post by:
I noticed that gets() reads into the buffer even if the you've not allocated enough memory. For instance, if you do: char *str=(char*)malloc(sizeof(char)); printf("Enter something about yourself below:\n\n"); gets(str); printf("\n\n"); puts(str);
by: Leandro Berti via DotNetMonster.com | last post by:
Hi All, I wrote a code to do serial communication with an equipament. When i use the code outside of threaded class it seens work properly, but when i put inside a class and execute a thread in the first seconds the communication is ok, later i receive read/write error. I?ve been in MSDN site and there i discover that the read/write error...
by: rich | last post by:
I am building an app using php and postgresql. My questionis this. How do you handle people wanting to make parallel changes to a record. Since in web apps you are doing a select, bring over a record then updating it, there is no lock on that record while you are making the changes in your browser window. Does transactions handle that? Do...
by: Jonah Bishop | last post by:
I'm developing a photo album web application for use on a web site, and I'm running into a problem with lengthy operations. My application allows the user to import a number of images at once into a photo album. For each image that gets imported, I create two thumbnail images (small and medium) and insert some data into a database. The...
by: gert | last post by:
This based on a example i found at http://www.cs.tut.fi/~jkorpela/ forms/cgic.html #include <fcgi_stdio.h> #include <stdlib.h> int urldecode(char *src, char *last, char *dest){ int code; for (; src != last; src++, dest++){ if (*src == '+') *dest = ' ';
by: wmihelpme | last post by:
Hi All, I have written a WMI Program which changes the network settings like ip address, subnet mask, gateway and dns addresses for given adapter number. when I call that function for adapter number-1, its executing perfectly. when I immediately make the call to that function with adapter number-2, its giving me the segmentation error and...
by: Lave | last post by:
Hi, all. I'm a new comer. So This question maybe sutpid.:) I want to write something that handle every char immediately after its input. Then tehe user don't need to type each time. How can I do this? Thanks in advance.
by: Lave | last post by:
Yes, it's what i want. Many thanks. BTW,python-list 's reply is so quick. I love it. I like you all guys. On 10/22/08, rishi pathak <mailmaverick666@gmail.comwrote: -- Regards
by: Terry Reedy | last post by:
rishi pathak wrote: Does not work on Windows, at least with 3.0, as tty fails trying to import termios. There, use msvcrt module "msvcrt.kbhit() Return true if a keypress is waiting to be read. msvcrt.getch() Read a keypress and return the resulting character. Nothing is echoed to the console. This call will block if a keypress is not...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.