Skip to content
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

GTK-Glade tutorial is out of date #3082

Closed
tobias47n9e opened this issue May 21, 2014 · 4 comments
Closed

GTK-Glade tutorial is out of date #3082

tobias47n9e opened this issue May 21, 2014 · 4 comments
Milestone

Comments

@tobias47n9e
Copy link
Contributor

The tutorial that puts a Matplotlib widget into a GTK application using the Glade interface designer, is out of date. The version used in the tutorial is Glade 2.x, and that file doesn't work anymore since Glade 3.x. It would be good to have a working tutorial for Glade 3.16 using GTK3.x (3.10 would be ideal), and Python 3.

I am trying to build a working example myself, but I just started with this kind of programming. So if anybody beats me to it, it would also be great and appreciated.

Python: https://github.com/matplotlib/matplotlib/blob/master/examples/user_interfaces/mpl_with_glade.py
Glade: https://github.com/matplotlib/matplotlib/blob/master/examples/user_interfaces/mpl_with_glade.glade

@tacaswell tacaswell added this to the v1.4.0 milestone May 21, 2014
@tacaswell
Copy link
Member

Maybe we want to just drop this section of the docs for 1.4.0 and put it back when we get it fixed?

@tobias47n9e
Copy link
Contributor Author

It might still work with Glade2.x and older versions of GTK. I just haven't tried that out. I have a working Python3-Glade3 application, but I just can't figure out how to place the matplotlib-widget into it.

@tobias47n9e
Copy link
Contributor Author

This it what I have so far. I can open a GTK-3.10 window by running a Python 3 program that opens a Glade 3.16.1-file.

My python 3 file:

#!/usr/bin/env python

from gi.repository import Gtk, Gio

from matplotlib.figure import Figure
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_simple.glade", ("window1", "") )
    builder.connect_signals(Window1Signals())

    window = builder.get_object("window1")
    window.show_all()

    Gtk.main()

if __name__ == "__main__":
    main()

and my glade file (name: "mpl_with_glade_simple.glade"):

<?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>
    <signal name="destroy" handler="on_window1_destroy" swapped="no"/>
    <child>
      <placeholder/>
    </child>
  </object>
</interface>

@tobias47n9e
Copy link
Contributor Author

I think I got it to work: #3088

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants