Example #1
0
"""
4 demo classes run as independent program processes: command lines;
if one window is quit now, the others will live on; there is no simple way to
run all report calls here (though sockets and pipes could be used for IPC), and
some launch schemes may drop child program stdout and disconnect parent/child;
"""
from tkinter import Tk, Label
from PP4E.launchmodes import PortableLauncher

demoModules = ['demoDlg', 'demoRadio', 'demoCheck', 'demoScale']

for demo in demoModules:  # see Parallel System Tools
    PortableLauncher(demo, demo + '.py')()  # start as top-level programs

root = Tk()
root.title('Processes')
Label(root, text='Multiple program demo: command lines', bg='white').pack()
root.mainloop()
Example #2
0
# GUI server side: read and display non-GUI script's output

import sys, os
from socket import *  # including socket.error
from Tkinter import Tk
from PP4E.launchmodes import PortableLauncher
from PP4E.Gui.Tools.guiStreams import GuiOutput

myport = 50008
sockobj = socket(AF_INET, SOCK_STREAM)  # GUI is server, script is client
sockobj.bind(('', myport))  # config server before client
sockobj.listen(5)

print('starting')
PortableLauncher('nongui', 'socket-nongui.py -gui')()  # spawn non-GUI script

print('accepting')
conn, addr = sockobj.accept()  # wait for client to connect
conn.setblocking(False)  # use nonblocking socket (False=0)
print('accepted')


def checkdata():
    try:
        message = conn.recv(1024)  # don't block for input
        #output.write(message + '\n')        # could do sys.stdout=output too
        print(message, file=output)  # if ready, show text in GUI window
    except error:  # raises socket.error if not ready
        print('no data')  # print to sys.stdout
    root.after(1000, checkdata)  # check once per second
Example #3
0
# e.g. 10-25

import sys, os
from socket import *
from tkinter import Tk
from PP4E.launchmodes import PortableLauncher
from PP4E.GUI.Tools.guiStreams import GuiOutput


myport = 50008
sockobj = socket(AF_INET, SOCK_STREAM)
sockobj.bind(('', myport))
sockobj.listen(5)

print('starting...')
PortableLauncher('nongui', 'socket-nongui.py -gui')()

print('accepting...')
conn, addr = sockobj.accept()
conn.setblocking(False)
print('accepted!')

def checkdata():
    try:
        message = conn.recv(1024)
        #output.write(message + '\n')
        print(message, file=output)
    except error:
        print('no data')
    root.after(1000, checkdata)
Example #4
0
 def spawn(self, pycmdline, wait=FALSE):
     if not wait:
         PortableLauncher(pycmdline, pycmdline)()
     else:
         System(pycmdline, pycmdline)()
Example #5
0
 def spawn(self, pycmdline, wait=False):
     if not wait:  # start new process
         PortableLauncher(pycmdline, pycmdline)()  # run Python progam
     else:
         System(pycmdline, pycmdline)()  # wait for it to exit