示例#1
0
def runLauncher(mytools, wtitle='TaklowKernewek GUI'):
    # put up a simple launcher bar for later use
    root = tk.Tk()
    root.title(wtitle)
    row1 = tk.Frame(root)
    row2 = tk.Frame(root)
    for (name, commandLine) in mytools[:5]:
        b = tk.Button(row1,
                      text=name,
                      fg='black',
                      bg='beige',
                      border=2,
                      command=PortableLauncher(name, commandLine))
        b.pack(side=tk.LEFT, expand=tk.YES, fill=tk.BOTH)
    row1.pack(side=tk.TOP, expand=tk.YES, fill=tk.BOTH)
    for (name, commandLine) in mytools[5:]:
        b = tk.Button(row2,
                      text=name,
                      fg='black',
                      bg='beige',
                      border=2,
                      command=PortableLauncher(name, commandLine))
        b.pack(side=tk.LEFT, expand=tk.YES, fill=tk.BOTH)
    row2.pack(side=tk.TOP, expand=tk.YES, fill=tk.BOTH)

    root.mainloop()
示例#2
0
def runImmediate(mytools):
    print('Starting Python/Tk gadgets...')
    for (name, commandLine) in mytools:
        PortableLauncher(name, commandLine)()
    print('One moment please ...')
    if sys.platform[:3] == 'win':
        for i in range(10):
            time.sleep(1)
            print('.' * 5 * (i + 1))
示例#3
0
def runImmediate(mytools):
    # launch gadget programs immediately
    print 'Starting Python/Tk gadgets...'  # msgs to temp stdout screen
    for (name, commandLine) in mytools:
        PortableLauncher(name, commandLine)()  # call now to start now
    print 'One moment please...'  # \b means a backspace
    if sys.platform[:3] == 'win':
        # on Windows keep stdio console window up for 5 seconds
        for i in range(5):
            time.sleep(1)
            print('\b' + '.' * 10),
示例#4
0
def runImmediate(mytools):
    """
    立即启动小工具程序
    """
    print('Starting Python/Tk gadgets...')  # 消息输出到标准输出
    for (name, commandLine) in mytools:
        PortableLauncher(name, commandLine)()  # 现在调用,即刻启动
    print('One moment please...')
    if sys.platform[:3] == 'win':  # 保留控制台10秒
        for i in range(10):
            time.sleep(1)
            print('.' * 5 * (i + 1))
示例#5
0
def runImmediate(mytools):
    """
    launch gadget programs immediately
    """
    print('Starting Python/Tk gadgets...')  # msgs to stdout (poss temp)
    for (name, commandLine) in mytools:
        PortableLauncher(name, commandLine)()  # call now to start now
    print('One moment please...')
    if sys.platform[:3] == 'win':  # windows: keep console 10 secs
        for i in range(10):
            time.sleep(1)
            print('.' * 5 * (i + 1))
示例#6
0
def runLauncher(mytools):
    root = MainWindow('PyGadgets PP4E')
    for (name, commandLine) in mytools:
        b = Button(root,
                   text=name,
                   fg='black',
                   bg='beige',
                   border=2,
                   command=PortableLauncher(name, commandLine))
        b.pack(side=LEFT, expand=YES, fill=BOTH)

    root.mainloop()
示例#7
0
def runImmediate(mytools):
    # launch programs immediately
    print('Yma ow talleth Python/Tk GUI rag taklowkernewek'
          )  # msgs to temp stdout screen
    for (name, commandLine) in mytools:
        PortableLauncher(name, commandLine)()  # call now to start now
    print('Unn pols mar pleg...')  # \b means a backspace
    if sys.platform[:3] == 'win':
        # on Windows keep stdio console window up for 5 seconds
        for i in range(5):
            time.sleep(1)
            print(('\b' + '.' * 10), end=' ')
示例#8
0
def runLauncher(mytools):
    # put up a simple launcher bar for later use
    root = Tk()
    root.title('PyGadgets PP3E')
    for (name, commandLine) in mytools:
        b = Button(root,
                   text=name,
                   fg='black',
                   bg='beige',
                   border=2,
                   command=PortableLauncher(name, commandLine))
        b.pack(side=LEFT, expand=YES, fill=BOTH)
    root.mainloop()
示例#9
0
def runLauncher(mytools):
    """
    pop up a simple launcher bar for later use
    """
    root = MainWindow('PyGadgets PP4E')  # or root = Tk() if prefer
    for (name, commandLine) in mytools:
        b = Button(root,
                   text=name,
                   fg='black',
                   bg='beige',
                   border=2,
                   command=PortableLauncher(name, commandLine))
        b.pack(side=LEFT, expand=YES, fill=BOTH)
    root.mainloop()
示例#10
0
def runLauncher(mytools):
    """
    弹出一个简单的启动器栏备用
    """
    root = MainWindow('PyGadgets Programming Python')  # 也可使用root=Tk()
    for (name, commandLine) in mytools:
        b = Button(root,
                   text=name,
                   fb='black',
                   bg='beige',
                   border=2,
                   command=PortableLauncher(name, commandLine))
        b.pack(side=LEFT, expand=YES, fill=BOTH)
    root.mainloop()
示例#11
0
# GUI server side: read and display non-GUI script's output

import sys, os
from socket import *
from tkinter import Tk
from launchmodes import PortableLauncher
from 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)
示例#12
0
"""
4 демонстрационных класса, выполняемых как независимые процессы: команды;
если теперь одно окно будет завершено щелчком на кнопке Quit, остальные
продолжат работу; в данном случае не существует простого способа вызвать все
методы report (впрочем, для организации взаимодействий между процессами можно
было бы воспользоваться сокетами и каналами), а кроме того, некоторые способы
запуска могут сбрасывать поток stdout дочерних программ и разрывать связь между
родителем и потомком;
"""
from tkinter import *
from launchmodes import PortableLauncher

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

for demo in demoModules:
    PortableLauncher(demo, demo + '.py')()
root = Tk()
root.title('Processes')
Label(root, text='Multiple program demo: command lines', bg='white').pack()
root.mainloop()
示例#13
0
 def spawn(self, pycmdline, wait=0):
     if not wait:
         PortableLauncher(pycmdline, pycmdline)()  # run Python progam
     else:
         System(pycmdline, pycmdline)()  # wait for it to exit
示例#14
0
 def spawn(self, pycmdline, wait=False):
     if not wait:  # запустить новый процесс
         PortableLauncher(pycmdline, pycmdline)()  # запустить программу
     else:
         System(pycmdline, pycmdline)()  # ждать ее завершения
示例#15
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 launchmodes import PortableLauncher
from gui_streams 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_non_gui.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.stdou=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
示例#16
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
示例#17
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 *
from 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()
示例#18
0
 def spawn(self, pycmdline, wait=False):
     if not wait:  # 启动新的进程
         PortableLauncher(pycmdline, pycmdline)()  # 运行python程序
     else:
         System(pycmdline, pycmdline)()  # 等待程序退出
示例#19
0
 def spawn(self, pycmdline, wait=False):
     if not wait:
         PortableLauncher(pycmdline, pycmdline)()
     else:
         System(pycmdline, pycmdline)()
示例#20
0
"""
4 демонстрационных класса, выполняемых как независимые процессы: команды;
если теперь одно окно будет завершено щелчком на кнопке Quit, остальные
продолжат работу; в данном случае не существует простого способа вызвать все
методы report (впрочем, для организации взаимодействий между процессами можно
было бы воспользоваться сокетами и каналами), а кроме того, некоторые способы
запуска могут сбрасывать поток stdout дочерних программ и разрывать связь между
родителем и потомком;
"""

from tkinter import *
from launchmodes import PortableLauncher

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

for demo in demoModules:  # смотрите главу 5
    PortableLauncher(demo, demo + '.py')()  # запуск в виде программ верхнего
    # уровня
root = Tk()
root.title('Processes')
Label(root, text='Multiple program demo: command lines', bg='white').pack()
root.mainloop()