There will be problems under windows
时光@记忆
时光@记忆 2020-03-04 18:45:39
0
0
870

# Click to execute the corresponding script
#? How to display the script's data
#? How to run and stop script
#? Possible problems

from runpy import run_path
from tkinter import *
# from multiprocessing import Process
import multiprocessing
# app exe -> id ---> pid (running id)

# |script| -> func1 -> func2 --> func3
# |App| -> display() & if do() -> update_style() & if do()
# Process

def make_app():
app = Tk()
app.geometry('300x500')
Button(text= 'run', command=run_script).pack()
Button(text='stop', command=stop_script).pack()
return app

def run_script():
print('hi there')
p = multiprocessing.Process(name='print', target=lambda:run_path('test.py'))
p.start()


def stop_script():
for p in multiprocessing.active_children():
if p.name == 'print':
p.terminate()

def watcher() :
print(multiprocessing.active_children())
app.after(1000, watcher)

if __name__ == '__main__':
app = make_app()
app. after(0, watcher)
app.mainloop()














##

时光@记忆
时光@记忆

既然选择了远方,便只顾风雨兼程

reply all (0)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!