Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I open two different pylab figures from the same button from a wxpython gui?
    primarykey
    data
    text
    <p>I am new to python and I have a serious problem that I cannot overcome. I have created a gui using wxpython that has two text fields and a button. When this button is pressed I call a function that call another function which creates a pie figure according to the input in text boxes. The problem is that if the user do not close the figure and enter new values to the textboxes and press again the button, the program crash instead of showing a second figure. I tried to create different threads when the button is pressed the result is the same. </p> <p>More specifically:</p> <p>this are the functions that are called when the button is clicked:</p> <p>def statistics_button(self,event):</p> <pre><code> t=threading.Thread(target=self.m_button21OnButtonClick,args=(event,)) t.start() print t def m_button21OnButtonClick( self, event ): '''some code here''' fig=statistics.mmr_dist(mmr1,mmr2) show() </code></pre> <p>the statistics_button is called first and then this calls the m_button21OnButtonClick. the statistics.mmr_dist function is the following:</p> <pre><code>'''some code''' fig=pylab.figure(tit,figsize=(8,8),frameon=False) ax=pylab.axes([0.1, 0.1, 0.8, 0.8]) pita=pylab.pie(db.values(), labels=tuple(db.keys()), autopct='%1.1f%%', shadow=True) ti="%s-%s\n Maximum Distance = %s m\n Minimum Distance = %s m" % (ddf1.label,ddf2.label,maxdist,mindist) title(ti, bbox={'facecolor':'0.8', 'pad':5}) '''some code''' return fig </code></pre> <p>So far I have understood that the show() command blocks the function m_button21OnButtonClick from finishing so it cannot be called again when the button is clicked unless the figure is closed. But this is the reason I implemented different threads. Though it doesn't seem to work.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload