Menu

[r513]: / trunk / htdocs / examples / embedding_in_gtk.py  Maximize  Restore  History

Download this file

42 lines (29 with data), 892 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
from matplotlib.numerix import arange, sin, pi
import matplotlib
matplotlib.use('GTKAgg') # or 'GTK'
from matplotlib.axes import Subplot
# swith comments for gtk over gtkagg
#from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas
from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas
from matplotlib.figure import Figure
import gtk
win = gtk.Window()
win.set_title("Embedding in GTK")
win.connect("destroy", gtk.mainquit)
vbox = gtk.VBox(spacing=3)
win.add(vbox)
f = Figure(figsize=(5,4), dpi=100)
a = f.add_subplot(111)
t = arange(0.0,3.0,0.01)
s = sin(2*pi*t)
a.plot(t,s)
canvas = FigureCanvas(f) # a gtk.DrawingArea
vbox.pack_start(canvas)
#button = gtk.Button('Quit')
#button.connect('clicked', lambda b: gtk.mainquit())
#button.show()
#vbox.pack_start(button)
win.show_all()
#gtk.mainloop()
gtk.main()
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.