关闭正在运行的程序

时间:2016-12-16 11:27:16

标签: python-2.7 multiprocessing easygui

如何从子进程中关闭程序? 例如:

import easygui
import multiprocessing

def func():
    reply=easygui.buttonbox("start?",image="F:\project\phonber.png",choices=['yes','no'])
    if reply=="yes":
        exit_option()


if __name__=='__main__':
    p=multiprocessing.Process(target=func,args=())
    t=p.start()
    while True:
        None

有没有办法执行exit_option()

1 个答案:

答案 0 :(得分:1)

你忘了实际调用这个函数:

 <!DOCTYPE html>
    <html>
    <head>
        <title></title>
    </head>
    <body>


    <div>
    Foundations
    <input type="range" name="s1" min="0" max="100"  id="bar1" value="0" oninput="mover1();" onchange="changeOne();">

    </div>
    <div>
    Walls
    <input type="range" name="s2" min="0" max="100"  id="bar2" value="0" style="margin-left: 1.9em;" onchange="changeTwo();">

    </div>
    <div>
    Roof
    <input type="range" name="s3" min="0" max="100" id="bar3" value="0" style="margin-left: 2.7em;" >
    </div>

       <script>  
        var bar1 = document.getElementById("bar1");
        var bar2 = document.getElementById("bar2");  
        var bar3 = document.getElementById("bar3"); 
            function changeOne()
            {

                bar2.setAttribute("max", bar1.value);
                bar3.setAttribute("max", bar2.value);
            }

             function changeTwo()
            {

                bar3.setAttribute("max", bar2.value);
            }

            </script>
    </body>
    </html>

然后,要实际杀死一个正在运行的进程,当然有很多选择。最明显的方法是import easygui import multiprocessing def func(): reply=easygui.buttonbox("start?",image="F:\project\phonber.png",choices=['yes','no']) if reply=="yes": exit_option() func() if __name__=='__main__': p=multiprocessing.Process(target=func,args=()) t=p.start() while True: None psutilkill方法,或terminate其kill方法。如图所示here