matplotlab freezes with a graph and toolbar

Hello. Through accident, I found that running the following script will freeze the computer. On my computer, the mouse still worked, but everything else still froze. I have minimalized the code and attached the script for your convienence:

import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
import Tkinter
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
from matplotlib.figure import Figure
class simpleapp_tk(Tkinter.Tk):#initialize
    def __init__(self,parent):
        Tkinter.Tk.__init__(self,parent)
        self.grid()
        self.figure = Figure(figsize=(5,4), dpi=100)
        canvas = FigureCanvasTkAgg(self.figure, master=self)
        canvas.show()
        canvas.get_tk_widget().grid(row=0,column=0)
        toolbar = NavigationToolbar2TkAgg( canvas, self )

if __name__ == "__main__":
    app = simpleapp_tk(None)
    app.title('Freezing computer...')
    app.mainloop()

I am running this on linux, YYY is my computer's name (confidential)
XXX@...3161...:~$ uname -a
Linux YYY 2.6.32-22-generic #36-Ubuntu SMP Thu Jun 3 22:02:19 UTC 2010 i686 GNU/Linux

I obtained my version from the linux repositories.

Mail me back if you fixed this bug or have any questions at ejg_dnd@...3162...

gridtestbug.py (656 Bytes)

I am not sure there is anything matplotlib can do about this. You can get into trouble mixing the packer (which matplotlib uses) with the grid manager even with straight Tkinter. An example is attached. It doesn't freeze X like your example, but it does sit in an endless loop.

In your example, I find that using ctrl-alt-F2 I can get to a console, but from there I haven't found any solution better than rebooting. Killing X should be an alternative, but it not as simple or obvious as it used to be. (I am also using ubuntu 10.04, but I run mpl from svn.)

Eric

tkpackgrid.py (332 Bytes)

···

On 06/15/2010 08:02 AM, Eliot Glairon wrote:

Hello. Through accident, I found that running the following script will freeze the computer. On my computer, the mouse still worked, but everything else still froze. I have minimalized the code and attached the script for your convienence:

import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
import Tkinter
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
from matplotlib.figure import Figure
class simpleapp_tk(Tkinter.Tk):#initialize
     def __init__(self,parent):
         Tkinter.Tk.__init__(self,parent)
         self.grid()
         self.figure = Figure(figsize=(5,4), dpi=100)
         canvas = FigureCanvasTkAgg(self.figure, master=self)
         canvas.show()
         canvas.get_tk_widget().grid(row=0,column=0)
         toolbar = NavigationToolbar2TkAgg( canvas, self )

if __name__ == "__main__":
     app = simpleapp_tk(None)
     app.title('Freezing computer...')
     app.mainloop()

I am running this on linux, YYY is my computer's name (confidential)
XXX@...3161...:~$ uname -a
Linux YYY 2.6.32-22-generic #36-Ubuntu SMP Thu Jun 3 22:02:19 UTC 2010 i686 GNU/Linux

I obtained my version from the linux repositories.

Mail me back if you fixed this bug or have any questions at ejg_dnd@...3162...

Hi,

is it helpful to write that both of you examples doesn't crash anything for me
(except the second only being able to be "$kill"ed)?

mdik@...3164...:~$ uname -a
Linux eee 2.6.29-2-686 #1 SMP Sun May 17 17:56:29 UTC 2009 i686 GNU/Linux
mdik@...3164...:~$ python --version
Python 2.5.5

Regards,

Malte

2010/6/15 Eliot Glairon <ejg_dnd@...9...>:

class simpleapp_tk(Tkinter.Tk):#initialize
def __init__(self,parent):
Tkinter.Tk.__init__(self,parent)
self.grid()

It sounds a bit odd to me to attemt to .grid() a Tk instance ... The
Tkinter.Tk() instance is the toplevel application window. You do not
have to grid it.

Also, I don't know what the *parent* argument means to to
Tkinter.Tk.__init__(). Try to leave the parent argument alone, and
try to remove the .grid().

Friedrich