问题
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