I try to display with matplotlib 2 plots (or more) and at the same time a popup box with a message (in a not sequential manner). It seems easy, but I do not succeed. I tryed 2 methods:
As seen on the two links above, 1. is not working for me.
Concerning the 2.:
2.1 with interactive on
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> import wx
>>> plt.ion()
>>> for i in range(3):
... plt.figure()
... plt.plot(np.random.rand(10))
...
<matplotlib.figure.Figure object at 0x2c56e90>
[<matplotlib.lines.Line2D object at 0x3ab7090>]
<matplotlib.figure.Figure object at 0x3ab7310>
[<matplotlib.lines.Line2D object at 0x3dff310>]
<matplotlib.figure.Figure object at 0x3dff590>
[<matplotlib.lines.Line2D object at 0x42372d0>]
>>> qualPara = wx.App(False)
>>> dlg = wx.MessageDialog(None, "toto", 'titi', wx.OK | wx.ICON_INFORMATION |wx.STAY_ON_TOP, pos=(-1,-1))
>>> dlg.ShowModal()
5100
>>>
(python:6268): Gdk-ERROR **: The program 'python' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadWindow (invalid Window parameter)'.
(Details: serial 1691 error_code 3 request_code 15 minor_code 0)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the --sync command line
option to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
Trace/BPT trap (core dumped)
2.2 with interactive off
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> import wx
>>> plt.ioff()
>>> for i in range(3):
... plt.figure()
... plt.plot(np.random.rand(10))
...
<matplotlib.figure.Figure object at 0x1f79e90>
[<matplotlib.lines.Line2D object at 0x2cc0410>]
<matplotlib.figure.Figure object at 0x2cc0690>
[<matplotlib.lines.Line2D object at 0x2ce9110>]
<matplotlib.figure.Figure object at 0x2ce9390>
[<matplotlib.lines.Line2D object at 0x30b7ed0>]
>>> plt.show(block=False)
>>> qualPara = wx.App(True)
>>> dlg = wx.MessageDialog(None, "toto", 'titi', wx.OK | wx.ICON_INFORMATION |wx.STAY_ON_TOP, pos=(-1,-1)
... )
>>> dlg.ShowModal()
>>>
(python:6315): Gdk-ERROR **: The program 'python' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadWindow (invalid Window parameter)'.
(Details: serial 3737 error_code 3 request_code 15 minor_code 0)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the --sync command line
option to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
Trace/BPT trap (core dumped)
An usual plot display is needed (zoomable, resizable, etc). For 2.1 and 2.2, all is fine until the wx.App Class uses. Plot displays become not resizable etc ... and finally I am exited from python interpreter with error message ... Because I observes the problem comes when I start to use wx concomitantly to matplotlib, I decided to rather use easygui.msgbox:
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from easygui import msgbox
>>> plt.ioff()
>>> for i in range(3):
... plt.figure()
... plt.plot(np.random.rand(10))
...
<matplotlib.figure.Figure object at 0x3c220d0>
[<matplotlib.lines.Line2D object at 0x3f8b950>]
<matplotlib.figure.Figure object at 0x3f8bbd0>
[<matplotlib.lines.Line2D object at 0x421b350>]
<matplotlib.figure.Figure object at 0x421b5d0>
[<matplotlib.lines.Line2D object at 0x424b150>]
>>> plt.show(block=False)
>>> if msgbox("toto",'titi') == 'OK':
... plt.close('all')
...
>>>
In this case, it is perfect, I obtained exactly what I wanted ... except (I am may be too purist !!!), in this case it is impossible to close the msgbox with the x-close corner ... I will very appreciate all remarks about all this story (threads not working 1., plt and wx not working together 2.) and if it is required to use only the 'OK' button to close the msgbox.