[Glade-users] Inserting a chart Matplotlib in a GUI using Glade (gtk)



Hello,

Has anyone had the experience of Matplotlib insert a chart in a GUI using
Glade (GTK), I'm having many difficulties, he gives no error, but no window
appears.

Below is the code, thank you if someone wants to talk about it.

Here attached the glade file.

#cod----

from __future__ import with_statement
from matplotlib.figure import Figure
from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as
FigureCanvas
from matplotlib.backends.backend_gtkagg import
NavigationToolbar2GTKAgg as NavigationToolbar
import gtk
import gtk.glade
import pygtk
pygtk.require('2.0')

class Teste:
    def __init__(self):
        self.widgets = gtk.glade.XML(fname='plugin.glade')
        self['winPlugin'].connect('destroy', lambda x:
gtk.main_quit())
        self['winPlugin'].set_default_size(200,200)
        fig = Figure(figsize=(5,4), dpi=100)
        ax = fig.add_subplot(111)
        ax.plot([1,2,3])
        self.canvas = FigureCanvas(fig)
        self['hbox7'].pack_start(self.canvas, True, True)
        self['hbox7'].show()
        self.navToolbar = NavigationToolbar(self.canvas,
self['winPlugin'])
        self.navToolbar.lastDir = '/var/tmp/'
        self['hbox7'].pack_start(self.navToolbar)
        self.navToolbar.show()

    def __getitem__(self, key):
        return self.widgets.get_widget(key)

widgets = Teste()
gtk.main()

#cod---


Atenciosamente,

-- 
Francisco Gerson Amorim de Meneses
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/glade-users/attachments/20120512/f98e3ef8/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plugin.glade
Type: application/octet-stream
Size: 23340 bytes
Desc: not available
URL: <http://lists.ximian.com/pipermail/glade-users/attachments/20120512/f98e3ef8/attachment-0001.obj>




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]