473,698 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Listening for a Keypress (Console, not GUI)

Hello All,

I've written a small daemon that monitors a pop3 mailbox and downloads
any new messages. It's run from the console in windows, and instead of
having it print something each time it gets a message or writes a file,
i'd like to store those values as internal variables and print them to
the screen whenever the user wants to see them.

So, my question is, using a regular console, is there a way I can get
python to listen for a specific keystroke? I'm using signal handling
to deal with ^C, could I also do something like that?

TIA

Jul 19 '05 #1
2 3084
Ok, I should really read my messages more carefully before posting, I
apologize.

This is what i'm envisioning

"Python Mail Service is running..."
<user presses S or something>

Status is printed like:

"Current Statistics"
Messages retrieved : 12345
Errors: 123
Total Files Written: 12345

Like that - again, apologies for my lack of detail in the first message

Jul 19 '05 #2
br****@gmail.co m wrote:
So, my question is, using a regular console, is there a way I can get
python to listen for a specific keystroke? I'm using signal handling
to deal with ^C, could I also do something like that?


This might help:

http://www.python.org/doc/faq/window...thout-blocking
--
Michael Hoffman
Jul 19 '05 #3

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

Similar topics

17
4223
by: MumboJumbo | last post by:
Hi I have a really basic question hopefully some can help me with: Can you write a (i.e. one) C# project that works from the cmd line and gui? I seems if i write a GUI app it can't write to console using System.Console.WriteLine if thge project has its "Output Type" to "Windows Application". However I can write to stdio if i set output type to "Console Application". When I do this I unfortunately get a "console box" as well
1
6174
by: Rene | last post by:
Hi, I am running is some problems with the KeyPreview and KeyPress events. The KeyPress event is only triggered when there this an focusable control on the form. When all controls are disabled the Form.KeyPress event does not trigger anymore. A way to 'solve' this is to set the focus to the form, but during testing it happens ofter the keypress event is not getting triggered on keys like
6
1666
by: metiu | last post by:
Say I have a console app that does something in three steps: - opens a file - transfers the file through a serial port - does some elaborations and I want to build a GUI around it that, for example, sets the file name to open or starts the different steps. I started using wxPython (actually boa-constructor) to build a frame with everything I want.
4
8627
by: eduardorp1 | last post by:
I have a GUI application that needs to be invoked from the command line as well. It should work both as a GUI and as a console application. When I invoke it from the command line, it reads all the command line options perfectly. However, I can't use Console.WriteLine to write messages to the console (the lines don't appear at the console window). Is it possible? What should I do to "connect" the console? My Main() is:
2
2071
by: wheels619 | last post by:
Hi, I have a program that has options to run as both a GUI and a console. The program entry point has a c# file with the "static main...." It checks some parameters, if no parameters, it launches the GUI by: if(args.Length == 0) { Application.Run(new MainForm()); }
3
1347
by: per9000 | last post by:
Hi, I've written a small app that I mostly want to run from the console. Sometimes I want the output in a GUI instead to facilitate a "Save As" feature etc. I created a nice form etc and the switch -g prints the output in my GUI instead of on the console. Now to my problem: when I start the GUI from the Console the console is "blocked" by my application. Can I somehow (by threading?) release the console and keep the GUI running?
4
10508
by: Peter Nimmo | last post by:
Hi, I am writting a windows application that I want to be able to act as if it where a Console application in certain circumstances, such as error logging. Whilst I have nearly got it, it doesn't seem to write to the screen in the way I would expect. The output is:
3
2241
by: Sheikko | last post by:
Sincerly is a little bit complicated to explain to you what I have in my mind, but I will try: Above all the problem is the type of data that I want to passe between these two applications. The complete application that I want to create consiste of two applications: - the console developped with VS C++, that use some libraries developped with Borland C++ - the GUI of application that interact with the console.
2
19290
by: Tony Johansson | last post by:
Hello! I have created a Control that consist of a label and a textbox.I have called this class ctlLabelTextbox. public partial class ctlLabelTextbox : UserControl { .... } The class that I have created for this purpose is derived from class UserControl.
0
8675
marktang
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9029
jinu1996
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8897
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8862
tracyyun
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7729
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6521
isladogs
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.