473,394 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

hide python window, con'td

Great! And now that it's hiding w/ .pyw, how would I kill it if I want?
Just log off, or is there a better way?

Kevin
May 26 '06 #1
4 1685
Bell, Kevin wrote:
Great! And now that it's hiding w/ .pyw, how would I kill it if I want?
Just log off, or is there a better way?

Kevin

Close it in the Task Manager?
May 26 '06 #2
Something that runs all day in the background is a perfect candidate
for being turned into a Service. That and servicemanager has a good
way of managing the task so that it doesn't take up lots of excess
CPU cycles that a "normal" application would take while sleeping
or unnecessarily looping. Pick up a copy of Mark Hammond's Python
Programming on Win32 book for example services in Python. You could
then start/stop the service with service manager or with net start/
net stop commands.

-Larry Bates

Bell, Kevin wrote:
Great! And now that it's hiding w/ .pyw, how would I kill it if I want?
Just log off, or is there a better way?

Kevin

May 26 '06 #3
Larry Bates wrote:
Something that runs all day in the background is a perfect candidate
for being turned into a Service. That and servicemanager has a good
way of managing the task so that it doesn't take up lots of excess
CPU cycles that a "normal" application would take while sleeping
or unnecessarily looping. Pick up a copy of Mark Hammond's Python
Programming on Win32 book for example services in Python. You could
then start/stop the service with service manager or with net start/
net stop commands.

-Larry Bates

Bell, Kevin wrote:
Great! And now that it's hiding w/ .pyw, how would I kill it if I want?
Just log off, or is there a better way?

Kevin

It is possible to get a background process in windows especially with
Python-2.4, but it's fairly hard.

try using

python runner.py dingo.py

where

###### runner.py
def bgScript(script,scriptArgs):
from _subprocess import CreateProcess
class STARTUPINFO:
dwFlags = 0
hStdInput = None
hStdOutput = None
hStdError = None
class pywintypes:
error = IOError
import sys
exe = sys.executable.replace('n.exe','nw.exe')
startupinfo = STARTUPINFO()
args = ''.join([' "%s"' % a for a in scriptArgs])
cmd = '"%s" "%s" %s' % (exe,script,args)
try:
hp, ht, pid, tid = CreateProcess(None, cmd,
# no special security
None, None,
0, #don't inherit standard handles
0x208,
None,
None,
startupinfo)
except pywintypes.error, e:
print str(e)

if __name__=='__main__':
import sys
bgScript(sys.argv[1],sys.argv[2:])
###### dingo.py
if __name__=='__main__':
import time
for i in xrange(15):
time.sleep(1)
######

dingo.py shoul be running in the background detached from the console.
Of course as others point out, the official way to do this stuff is to
use all the M$ paraphernalia and have stuff start up at boot time etc etc.
--
Robin Becker
May 26 '06 #4
It is just the nature of "things that run in the background all
day" to be things that should probably be daemons or services.
They almost always sleep, check, process, sleep, ... and as
windows services do that better than processes in loops that
sleep. They are daunting at first, but services aren't really
all that hard to write after you first one.

Larry Bates

Robin Becker wrote:
Larry Bates wrote:
Something that runs all day in the background is a perfect candidate
for being turned into a Service. That and servicemanager has a good
way of managing the task so that it doesn't take up lots of excess
CPU cycles that a "normal" application would take while sleeping
or unnecessarily looping. Pick up a copy of Mark Hammond's Python
Programming on Win32 book for example services in Python. You could
then start/stop the service with service manager or with net start/
net stop commands.

-Larry Bates

Bell, Kevin wrote:
Great! And now that it's hiding w/ .pyw, how would I kill it if I want?
Just log off, or is there a better way?

Kevin

It is possible to get a background process in windows especially with
Python-2.4, but it's fairly hard.

try using

python runner.py dingo.py

where

###### runner.py
def bgScript(script,scriptArgs):
from _subprocess import CreateProcess
class STARTUPINFO:
dwFlags = 0
hStdInput = None
hStdOutput = None
hStdError = None
class pywintypes:
error = IOError
import sys
exe = sys.executable.replace('n.exe','nw.exe')
startupinfo = STARTUPINFO()
args = ''.join([' "%s"' % a for a in scriptArgs])
cmd = '"%s" "%s" %s' % (exe,script,args)
try:
hp, ht, pid, tid = CreateProcess(None, cmd,
# no special security
None, None,
0, #don't inherit standard handles
0x208,
None,
None,
startupinfo)
except pywintypes.error, e:
print str(e)

if __name__=='__main__':
import sys
bgScript(sys.argv[1],sys.argv[2:])
###### dingo.py
if __name__=='__main__':
import time
for i in xrange(15):
time.sleep(1)
######

dingo.py shoul be running in the background detached from the console.
Of course as others point out, the official way to do this stuff is to
use all the M$ paraphernalia and have stuff start up at boot time etc etc.

May 26 '06 #5

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

Similar topics

4
by: Aly | last post by:
I am building a site that sells 3 standard packages and one custom package. On the package selection page, I want the following: Upon loading the page, I want the package selections (Basic,...
4
by: Jon | last post by:
Hi, I am calling the function showpopupWindow(item) to open and write a popup window. When testing in IE6 locally the popup window displays my text in both the title and status bars but when...
1
nirmalsingh
by: nirmalsingh | last post by:
i want to hide a td value to the users. how to make hide the values in <td> of html table? i have tried width=0px, width="0%". but it doesnt works.
8
omerbutt
by: omerbutt | last post by:
i am new to javascipt and i want to print a selected area of the asp page to print through javascript ...is there any solution plz guide
1
by: pamate | last post by:
hi, I want to show hide layers. I am able to show and hide layers but i am facing problem that, cant view the cursor in Mozilla,but i can type in input text box, its overlapping the layers. ...
13
by: amymcdo3 | last post by:
Hi Everyone, I have a popup window that opens when clicking a link. The pop up window asks a question and supplies two buttons, Yes and No. The buttons are images and when the user clicks the...
1
by: abhishekbrave | last post by:
The code below is opening a calendar on mouse over in the same window. I need the calendar to be opened in new window. Have to fulfill this requirement urgentely so posting the whole code here. I...
0
by: atencorps | last post by:
Hello I have the following code but need some help on it. The idea of the code is the main sections ie Service Management are viewable when the page is loaded and by clicking on the main...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...

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.