Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
251b89f
first commit
tobias47n9e May 26, 2014
0d216e6
python3 shebang
tobias47n9e May 28, 2014
5b1eb12
figures
tobias47n9e Jun 4, 2014
3694d33
user guide structure
tobias47n9e Jun 5, 2014
ed7c044
mouse tracking tutorial for glade and some more changes
tobias47n9e Jun 7, 2014
ebe261e
reworded ui_introduction.rst
tobias47n9e Jun 13, 2014
bb2766c
Merge remote-tracking branch 'upstream/master'
tobias47n9e Jun 24, 2014
4fc9fa4
removing tutorial files
tobias47n9e Jun 25, 2014
40b41e2
fixed wrong diff?
tobias47n9e Jun 25, 2014
2025d3a
small error in comment
rahiel May 26, 2014
9d7afc7
Fix bug in setting y-axis minimum in histograms with weights and log …
May 26, 2014
fc5d9e1
fix argument checks in axis/base.margins
andreasWallner May 20, 2014
9ae56df
removed unnecessary image checks in test_axes.test_margins
andreasWallner May 20, 2014
e036000
added missing cleanup on testbench function
andreasWallner May 21, 2014
f716ffc
Fix for bug #3029.
razius May 16, 2014
411bf08
doc changed
fariza Mar 26, 2014
2c229fe
doc string mod
fariza May 5, 2014
e532782
Image: handle images with zero columns or rows.
efiring Jun 1, 2014
7535299
Streamplot: clean up handling of masks, eliminate warning in test.
efiring Jun 1, 2014
e5abe80
BUG: in Spine.set_position(), preserve most Axis info.
efiring Jun 1, 2014
33346c7
Use autolim kwarg in add_collection to prevent duplication of effort.
efiring Jun 1, 2014
977d718
Adds check that rgb sequence is of length 3
GregoryAshton May 28, 2014
5c163a0
Improves check of arg range
GregoryAshton May 28, 2014
bc38dca
Removes unnecessary float conversions
GregoryAshton May 29, 2014
6e9f34f
Fixed small bug in Appender class in docstring module.
cgringmuth Jun 2, 2014
f420bfe
DOC : clarified doc of add_artist
tacaswell Jun 3, 2014
f55f196
bug fix: check the type of the 'key' of the two array 'r1' and 'r2'
montefra Jun 3, 2014
af4cf43
Error message written in proper English
montefra Jun 3, 2014
bef70dc
New animation example inspired from the Joy Division's Unchained Love…
rougier May 31, 2014
351bc73
DOC : fixed urls
tacaswell Jun 5, 2014
6a014d0
typo fix
stahlous Jun 7, 2014
57f3fd9
DOC : add documentation to Polygon methods
tacaswell Jun 7, 2014
d7b3364
errorbar: fmt kwarg default is ''; deprecate None, use 'none' instead
efiring Jun 1, 2014
798001d
DOC : added aspect to pyplot.axes doc
tacaswell Jun 7, 2014
ba69531
DOC : Added link to axes.Axes.set_aspect
tacaswell Jun 8, 2014
d505cc4
DOC : added inherited-members to Axes autodoc
tacaswell Jun 8, 2014
bd02df0
DOC : Added docstrings to _CollectionWithSizes
tacaswell Jun 8, 2014
f8424cd
DOC : tweaked Collection api auto-doc properties
tacaswell Jun 8, 2014
66fbb41
DOC : added whats_new entry for _CollectionWithSizes
tacaswell Jun 8, 2014
4853892
DOC: mention Anaconda; clean some old junk out of the FAQ
efiring Jun 7, 2014
f47dcc2
BUG : don't use mutable objects as dictionary keys
tacaswell Mar 25, 2014
89ec797
DOC : added note about maintain ref to widgets
tacaswell Jun 10, 2014
5220a57
DOC : improved docs in widgets.py
tacaswell Jun 10, 2014
2d2981b
DOC : sixify unichr
tacaswell Jun 9, 2014
c35ee74
MNT : six-ified BytesIO import in pdf backend
tacaswell Jun 10, 2014
2b0c6a1
Adding Colorbar.remove()
KevKeating Jun 10, 2014
2873a8c
DOC : merged offsetbox.rst into artists_api.rst
tacaswell Jun 10, 2014
7e2df7e
DOC : added examples index to contents page
tacaswell Jun 10, 2014
54f225f
DOC : removed out-dated example
tacaswell Jun 10, 2014
2cd9e0a
DOC : fixed section titles
tacaswell Jun 10, 2014
09bdd3a
DOC : fixed section hierarchy
tacaswell Jun 10, 2014
685e213
DOC : fixed rst formatting
tacaswell Jun 10, 2014
3aaca79
DOC : commented out non-existent file
tacaswell Jun 10, 2014
26d9cca
DOC : updated mpl_toolkits
tacaswell Jun 10, 2014
cd20633
DOC : fixed typo
tacaswell Jun 11, 2014
52a3315
DOC : updated seaborn blurb
tacaswell Jun 11, 2014
1e92661
removing tutorial files
tobias47n9e Jun 25, 2014
fd44b8a
fixed wrong diff?
tobias47n9e Jun 25, 2014
b68bb89
Merge branch 'master' of https://github.com/spiessbuerger/matplotlib
tobias47n9e Jun 25, 2014
729189d
testchange
tobias47n9e Jun 26, 2014
687a0db
Added a Glade GTK3 integration example.
tobias47n9e Jun 27, 2014
8dc4187
testchange2
tobias47n9e Jun 27, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
mouse tracking tutorial for glade and some more changes
  • Loading branch information
tobias47n9e committed Jun 7, 2014
commit ed7c0443969ca61ead968dc9c761134969569530
1 change: 1 addition & 0 deletions doc/users/index_user_interface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ User interface integration
ui_introduction.rst
ui_glade.rst
ui_gtk.rst
ui_wxwidgets.rst

152 changes: 147 additions & 5 deletions doc/users/ui_glade.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ Glade user interface designer

Glade is a rapid-application-development program (RAD) or graphical user-interface-builder, that allows the easy creation of Gtk-applications. The user interface is stored in an XML-file (file extension: *".glade"*), which is called by the main program. The older version of Glade, 3.8.x, targets Gtk+ 2.x applications, while the newer 3.16.x, targets Gtk+ 3.x.

.. _ui_glade_316_python3:
.. _ui_glade_316_python3_basic:

Glade 3.16 example using Python 3
---------------------------------
Basic Glade 3.16 example using Python 3
---------------------------------------
This example uses Glade 3.16.x and Python 3.x. In order to understand the code it is recommended to work through the Python-GtK3-Tutorial: http://python-gtk-3-tutorial.readthedocs.org/en/latest/.

The first step is to start Glade and open a new project. Drag a *GtkApplicationWindow* into the work area. In the bottom-right menu you can change the default name from *"applicationwindow1"* to *"window1"*. This is the designation that the window will have in the Python 3 code and in Glade for certain actions. In the *Signals* tab of the same menu open the *GtkWidget* tree and find the *destroy* entry. This is the widget that will allow you to connect the program with the close-button of the window. Enter the action *"on_window1_destroy"* (window1 being the name we gave this window).
The first step is to start Glade and open a new project. This version of Glade will automaticall target GTK+ 3.x. The specific GTK version can be set in *File --> Properties*. To beginn the design phase drag a *GtkApplicationWindow* into the work area. In the bottom-right menu you can change the default name from *"applicationwindow1"* to *"window1"*. This is the designation that the window will have in the Python 3 code and in Glade for certain actions. In the *Signals* tab of the same menu open the *GtkWidget* tree and find the *destroy* entry. This is the widget that will allow you to connect the program with the close-button of the window. Enter the action *"on_window1_destroy"* (window1 being the name we gave this window).

In the next step we need to create a container to place the Matplotlib-widget. This tutorial uses a *GtkScrolledWindow*, which you can drag-and-drop on the *GtkApplicationWindow*. Now we are going to save the Glade file into directory with the name *"mpl_with_glade_316.glade"*. Note that there are many options in Glade you can additionally set like the default size of the window. These options are fairly easy to set.

Expand Down Expand Up @@ -224,4 +224,146 @@ The finished second example is shown in **Figure 3**.
:alt: Figure of the Glade interface, showing how to divide the window into 2 scrolled windows.
:align: left

**Figure 3:** The finished program (shown here in Ubuntu 14.04).
**Figure 3:** The finished program (shown here in Ubuntu 14.04).


.. _ui_glade_316_mouse_tracking:

Mouse tracking using Glade 3.16
-------------------------------
Although the *Matplotlib-NavigationToolbar* displays the mouse position within the plot, we might wan't to display this separatly in a different part of the window. This is often done in the toolbar of a window. Adding this functionality just requires a few lines of code and some changes to the user interface in Glade.

In Glade we will need to change the number of rows in the *GtkBox* to 3. Then drag a *GtkStatusbar* into the bottom-most cell. By default this statusbar will have the name statusbar1, which we can keep. The finished glade-file will look like this:

::

<?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">300</property>
<property name="default_height">200</property>
<signal name="destroy" handler="on_window1_destroy" swapped="no"/>
<child>
<object class="GtkBox" id="box2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="width_request">700</property>
<property name="height_request">600</property>
<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>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow2">
<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>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkStatusbar" id="statusbar1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">10</property>
<property name="margin_right">10</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

In the Python-3-code we need add a line that initializes the statusbar, a function that calculates and displays the mouse position, and a line that calls that function in the main loop:

::

#!/usr/bin/env python3

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
from matplotlib.backends.backend_gtk3 import NavigationToolbar2GTK3 as NavigationToolbar

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_ntb_ct.glade", ("window1", "") )
builder.connect_signals(Window1Signals())

window = builder.get_object("window1")

sw1 = builder.get_object("scrolledwindow1")
sw2 = builder.get_object("scrolledwindow2")
st1 = builder.get_object("statusbar1")

def updatecursorposition(event):
if event.inaxes:
x = event.xdata
y = event.ydata
st1.push(2, ("Coordinates: " + "x= " + str(x) + " y= " + str(y)))

figure = Figure(figsize=(4,3), 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)
sw1.add_with_viewport(canvas)

toolbar = NavigationToolbar(canvas, window)
sw2.add_with_viewport(toolbar)

canvas.mpl_connect('motion_notify_event', updatecursorposition)

window.show_all()
Gtk.main()

if __name__ == "__main__":
main()
6 changes: 5 additions & 1 deletion doc/users/ui_introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ The following user-interface frameworks are supported (graphical builders in bra
- Qt4
- Qt5
- Tk
- Wx

- Wx (wxFormbuilder)

- Wx 2.x
- Wx 3.x

The different frameworks offer different features and programming-language bindings. The appearance of the user interface will be, by default, similar to the style of the operating system, but can be customized.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a duplicate of the above paragraph


Expand Down
18 changes: 18 additions & 0 deletions doc/users/ui_wxwidgets.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.. _ui_wxwidgets:

wxWidgets
=========
wxWidgets is a user-interface toolkit that supports all common operating systems.

.. _ui_wx_mouse_tracking:

Mouse tracking and changing
---------------------------