Inserting a chart Matplotlib in a GUI using Glade (gtk)
Francisco Gerson Amorim de Meneses <[email protected]>
| Newsgroups | gmane.comp.gnome.glade.user |
|---|---|
| Message-ID | <CAJ+6O8FdhLCNnTtE1ga1=ufpQUX-R=G7dzVJBzg8yjN_0PvG0Q@mail.gmail.com> |
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
_______________________________________________
Glade-users maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/glade-users
plugin.glade
(application/octet-stream, 22.8 KB) - not displayed