How to avoid freezing of GUI while linking python muliprocessing script linked to a gui (python script should run in background)

老子叫甜甜 提交于 2020-01-05 05:49:09

问题


I have python script linked to gui and which runs in background.Based on the input from the GUI the python script should send messages accordingly.But as soon as I link my script( where I am using multiprocessing) to GUI,Screen freezes.Is there anything that I am doing wrong?Please provide me a solution.

from multiprocessing import Process
slider_perc= [0.0 ,10.0,20.0,30.0,40.0,50,60.0,70.0,80.0,90.0,100]           
slider_output_msg=["a","b","c","d","e","f","g","h","i","j"]

Slider_dictionary=dict(zip(slider_perc,slider_output_msg))
def change_slider():
    slider_pos=myAppl.Variable(slider).Read()
    slider_pos_round=int(round(slider_pos,-1))

    Desired_slider_Position=dict((k,Slider_dictionary[k]) for k in  [slider_pos_round] if k in Slider_dictionary)
    Desired_slider_Message=Desired_slider_Position.values()
    TxMessage_out=Desired_slider_Message
    status = vt.GetMessageResponse(TxMessage_out,RxPattern,Timeout,Flag)
def main():
    p = Process(target=change_slider())
    p.start()
    p.join()
main()

来源:https://stackoverflow.com/questions/38835662/how-to-avoid-freezing-of-gui-while-linking-python-muliprocessing-script-linked-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!