Use in a non-sequential manner of easygui.msgbox

2019-09-19 13:39发布

问题:

If I want display a plotting, with for example matplotlib, AND a popup message with easygui:

plt.show()

msgbox("Hello world", title="Hello")

it is needed to X-close the plotting window to see the popup windows (sequential read of the script). But if I want to display both at the same time?

回答1:

You can use the non-blocking show modes, but then you lose interactivity. You can instead use threads:

from easygui import msgbox
from matplotlib.pyplot import show, plot, draw, ion
from threading import Thread

p = Thread(target=msgbox, args=("Hello world",), kwargs=dict(title="Hello"))
p.start()

plot([1,2,3])
show()

p.join()