8000 Glade tutorial branch fixed by WeatherGod · Pull Request #3160 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Glade tutorial branch fixed #3160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jun 28, 2014
Next Next commit
first commit
  • Loading branch information
tobias47n9e authored and WeatherGod committed Jun 27, 2014
commit 5919ce3393e668feaff470d2b10dfefde5269d90
23 changes: 23 additions & 0 deletions examples/user_interfaces/mpl_with_glade_316.glade
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.16.1 -->
<interface>
<requires lib="gtk+" version="3.10"/>
<object class="GtkApplicationWindow" id="window1">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Matplotlib</property>
<property name="default_width">800</property>
<property name="default_height">600</property>
<signal name="destroy" handler="on_window1_destroy" swapped="no"/>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="border_width">10</property>
<property name="shadow_type">in</property>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</interface>
44 changes: 44 additions & 0 deletions examples/user_interfaces/mpl_with_glade_316.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python

from gi.repository import Gtk, Gio

from matplotlib.figure import Figure
from matplotlib.axes import Subplot
from numpy import arange, sin, pi
from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigureCanvas

import sys

class Window1Signals:
def on_window1_destroy(self, widget):
Gtk.main_quit()

def main():
builder = Gtk.Builder()
builder.add_objects_from_file("mpl_with_glade_316.glade", ("window1", "") )
builder.connect_signals(Window1Signals())
window = builder.get_object("window1")
sw = builder.get_object("scrolledwindow1")

#Start of Matplotlib specific code
##########################################################################
figure = Figure(figsize=(8,6), dpi=71)
axis = figure.add_subplot(111)
t = arange(0.0, 3.0, 0.01)
s = sin(2*pi*t)
axis.plot(t,s)

axis.set_xlabel('time [s]')
axis.set_ylabel('voltage [V]')

canvas = FigureCanvas(figure) # a Gtk.DrawingArea
canvas.set_size_request(800,600)
sw.add_with_viewport(canvas)
##########################################################################
#End of Matplotlib specific code

window.show_all()
Gtk.main()

if __name__ == "__main__":
main()
0