[Tutor] TSR in windows
Jeff Shannon
jeff@ccvcorp.com
Thu Jun 19 14:48:02 2003
Magnus Lycke wrote:
> At 12:21 2003-06-19 +0100, Patrick Kirk wrote:
>
>> I'm writing a little application that will log all contact received
>> on port 6346. It works a treat except...it leaves a console window
>> open. Right now I want to learn how to start it in the background and
>> then I will find a way to give it a System Tray icon.
>
>
> Rename the file from something.py to something.pyw, or alternatively,
> start the program with pythonw.exe instead of python.exe. (That's
> what .pyw is associated with in Windows.)
If this is only to run on Windows with an NT base (NT4, 2K, XP), you can
also create this as a Windows Service. This is a somewhat more involved
process, but it's very well described in the book "Python Programming on
Win32". (One of my first significant Python projects runs as a service,
so it's not hard to do.) This won't get you a System Tray icon or any
sort of user interface, but it will get you something that runs reliably
in the background and restarts itself every time that Windows is rebooted.
If you want something that runs in the system tray, though, you'll need
to use some sort of GUI toolkit such as wxPython. I'm not sure how that
might interact with the service framework, or if it will cooperate at
all... (Services are generally not meant to have a GUI; those that do,
it's typically a separate program that saves configuration parameters
and then restarts the service with the new parameters.)
Jeff Shannon
Technician/Programmer
Credit International