I'm quite new to python but I've spent my last week trying to code a software to visualize some weavy thingy.
The basic cinematic is: the user enters every information needed into a GUI then click proceed and I have an other big function to genereate all the graphics.
This was working but the problem was that when I ran the function, which lasts like 2 minutes, the tkinter window was freezing. I read that I should use threads. Then I found this: http://uucode.com/texts/pylongopgui/pyguiapp.html This is an example that basicaly does what I want plus some other things.
I'm now trying to adapt my code to make it fit this.
And here is my problem: everything seems to work fine except that at one moment in my function a new window called "tk" pop up and everything freeze.
Everything freeze at this moment:
# On trace les fils de chaine
for i in range(0, Couches_Trame + 1):
t = np.arange(0, np.pi, 0.1)
plt.figure(i)
plt.title('Plan de Trame ' + str(i+1), fontsize = '16')
ax = plt.gca()
ax.yaxis.set_visible(False)
ax.xaxis.set_visible(False)
plt.axis([-1, Plans, Fils_Chaine + 1, -1])
for j in range(0,Plans):
for k in range(0,Fils_Chaine):
plt.fill_between(np.cos(t)/8+j, np.sin(t+np.pi)/8+k+0.5, \
np.sin(t)/8+k+0.5, color='r')
plt.savefig('Blabla'+int(i))
plt.figure(Couches_Trame)
plt.title('Plan de Trame: Projection')
When I run it directly without using Tkinter everything works fine so I have no idea what's causing this.
Also I've tried replacing this piece of code by and infinite loop like this:
i=1
while i > 0:
i=i+1
print(i)
This works and nothing is freezing. But then I tried this:
i=1
while i > 0:
i=i+1
plt.plot((i,i))
And everything freezes and the window called "tk" pop-up and instantly freezes.
I read somewhere that this could be a conflict beetwen Tkinter and matplotlib backend but that's all and this didn't help me much.
Edit: I don't know if this help but I'm using Python Portble 2.7.2.1