Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Python window control?

If you have a question or need help, this is the place to be.
Post Reply
sideone
Posts: 4
Joined: Tue Mar 05, 2013 4:33 pm

Python window control?

Post by sideone »

Lately, I have been integrating a bunch of insteon HA devices with my existing EG configuration. I have configured simple python scripts throughout my lighting scene commands. I notice a black window briefly appearing when each python command is executed. I am not concerned with any results from the commands. Is it possible to hide these windows?

thanks.

sone
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Python window control?

Post by Pako »

sideone wrote:Is it possible to hide these windows?
Yes, it is of course possible. You can find many examples on the Internet.
It might look like this:

Code: Select all

subprocess.Popen(['insteon_command.bat'], shell=True, creationflags=subprocess.SW_HIDE)
Pako
sideone
Posts: 4
Joined: Tue Mar 05, 2013 4:33 pm

Re: Python window control?

Post by sideone »

Pako-

I am new to python, but assumed the issue was from the eg and not the subprocess output. I have adjusted all my scripts with this code, and now my system is finally integrated!!

Is it possible to spawn the python scripts so that EG doesn't pause while subprocess and sleep commands are processing?

thank you very much for the assistance!
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Python window control?

Post by Pako »

sideone wrote:Is it possible to spawn the python scripts so that EG doesn't pause while subprocess and sleep commands are processing?
Of course, it is quite often the case.
You need threading.
Here is an example:

Code: Select all

from threading import Thread
from time import sleep

def time_consumingScript(var1, var2, var3):
    print "############################################ Thread start"
    print "%s + %s =" % (str(var2),str(var3)), var2 + var3
    sleep(var1)
    print "############################################ Thread stop"
    
t = Thread(target = time_consumingScript, args = [20, 3, 7])
t.start()
Pako
Post Reply