473,545 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1697
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,arg s)
try:
hp, ht, pid, tid = CreateProcess(N one, cmd,
# no special security
None, None,
0, #don't inherit standard handles
0x208,
None,
None,
startupinfo)
except pywintypes.erro r, e:
print str(e)

if __name__=='__ma in__':
import sys
bgScript(sys.ar gv[1],sys.argv[2:])
###### dingo.py
if __name__=='__ma in__':
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,arg s)
try:
hp, ht, pid, tid = CreateProcess(N one, cmd,
# no special security
None, None,
0, #don't inherit standard handles
0x208,
None,
None,
startupinfo)
except pywintypes.erro r, e:
print str(e)

if __name__=='__ma in__':
import sys
bgScript(sys.ar gv[1],sys.argv[2:])
###### dingo.py
if __name__=='__ma in__':
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
5391
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, Standard, Advanced, and Custom) to be visible, as well as an Email field and Payment Method field. I want nothing to happen when Basic, Standard, or...
4
10313
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 viewed online from my website the titlebar text is preceded by the full URL and a - ( eg http://www.........co.uk - text I want to display) and the...
1
30816
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
3402
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
4152
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. I don`t want to change the way i have used to show and hide layers. check down code :- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0...
13
3211
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 button, they will either be linked to another page via the Yes button or they will stay on the same page if they click the No button. The popup window...
1
3694
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 tried doing some workaround using window.open() but not getting the calendar in new window. <html> <head> <script language="JavaScript">
0
1959
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 titles/headings or clicking on the 'expand all' will allow you to view the items underneath each title/heading. The page seems to be broken at the...
0
7669
Oralloy
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. ...
0
7926
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...
1
7439
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...
1
5343
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...
0
3468
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...
0
3450
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1901
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
1
1028
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
722
bsmnconsultancy
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.