You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/users/ui_glade.rst
+147-5Lines changed: 147 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -5,13 +5,13 @@ Glade user interface designer
5
5
6
6
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.
7
7
8
-
.. _ui_glade_316_python3:
8
+
.. _ui_glade_316_python3_basic:
9
9
10
-
Glade 3.16 example using Python 3
11
-
---------------------------------
10
+
Basic Glade 3.16 example using Python 3
11
+
---------------------------------------
12
12
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/.
13
13
14
-
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).
14
+
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).
15
15
16
16
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.
17
17
@@ -224,4 +224,146 @@ The finished second example is shown in **Figure 3**.
224
224
:alt:Figure of the Glade interface, showing how to divide the window into 2 scrolled windows.
225
225
:align:left
226
226
227
-
**Figure 3:** The finished program (shown here in Ubuntu 14.04).
227
+
**Figure 3:** The finished program (shown here in Ubuntu 14.04).
228
+
229
+
230
+
.. _ui_glade_316_mouse_tracking:
231
+
232
+
Mouse tracking using Glade 3.16
233
+
-------------------------------
234
+
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.
235
+
236
+
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:
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:
312
+
313
+
::
314
+
315
+
#!/usr/bin/env python3
316
+
317
+
from gi.repository import Gtk, Gio
318
+
319
+
from matplotlib.figure import Figure
320
+
from matplotlib.axes import Subplot
321
+
from numpy import arange, sin, pi
322
+
from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigureCanvas
323
+
from matplotlib.backends.backend_gtk3 import NavigationToolbar2GTK3 as NavigationToolbar
Copy file name to clipboardExpand all lines: doc/users/ui_introduction.rst
+5-1Lines changed: 5 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,11 @@ The following user-interface frameworks are supported (graphical builders in bra
26
26
- Qt4
27
27
- Qt5
28
28
- Tk
29
-
- Wx
29
+
30
+
- Wx (wxFormbuilder)
31
+
32
+
- Wx 2.x
33
+
- Wx 3.x
30
34
31
35
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.
0 commit comments