Skip to content

GTK-Glade tutorial is out of date #3082

Closed

Description

@tobias47n9e

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

Activity

  1. added this to the v1.4.0 milestone on May 21, 2014
  2. tacaswell commented on May 21, 2014

    @tacaswell
    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?

  3. tobias47n9e commented on May 21, 2014

    @tobias47n9e
    ContributorAuthor

    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.

  4. tobias47n9e commented on May 22, 2014

    @tobias47n9e
    ContributorAuthor

    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>
    
  5. tobias47n9e commented on May 26, 2014

    @tobias47n9e
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions