[Matplotlib-users] Use of Pyplot in a GUI script

Benjamin Root ben.v.root at gmail.com
Thu May 19 12:10:13 EDT 2016


Does that still work with current matplotlib? The import of pyplot triggers
the call to pylab_setup(), which causes matplotlib to assume that it will
be responsible for managing the windows.

It might also be that Tkinter might be the odd backend in this case and
that this wouldn't be portable to other backends. The tkagg backend has a
bunch of oddities that makes it different from the others.

On Thu, May 19, 2016 at 8:12 AM, Jason Swails <jason.swails at gmail.com>
wrote:

> FWIW, I wrote a Tkinter-based GUI program several years ago where I
> embedded a matplotlib canvas in my own window, and I used pyplot just
> fine.  I put it up on GitHub yesterday which you can use as an example (
> https://github.com/swails/mdout_analyzer) in case it helps.
>
> For me, also, the key ingredient was setting the Tk backend to avoid
> competing mainloops for the different GUI toolkits.  The reason I embedded
> the matplotlib graphs in my own window is so that I could destroy those
> windows when the main control window was closed (if you rely on matplotlib
> to create the windows for you, you can't control that window as easily from
> other parts of your application).
>
> All the best,
> Jason
>
> On Wed, May 18, 2016 at 1:05 PM, Eric's Gmail <eric.shain at gmail.com>
> wrote:
>
>> Awesome!
>>
>> This works so long as I callout before the importing of pyplot.
>>
>> Eric
>>
>> On May 18, 2016, at 11:13 AM, Eric Firing <efiring at hawaii.edu> wrote:
>>
>> matplotlib.use('tkagg')
>>
>>
>>
>> _______________________________________________
>> Matplotlib-users mailing list
>> Matplotlib-users at python.org
>> https://mail.python.org/mailman/listinfo/matplotlib-users
>>
>>
>
>
> --
> Jason M. Swails
>
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20160519/57296a35/attachment.html>


More information about the Matplotlib-users mailing list