Commit a0800604 authored by David Boddie's avatar David Boddie

A second pass on the tutorial, making corrections

Remove unused module import from the main program.
parent 195ddaf0
......@@ -17,6 +17,9 @@ Name Description
The first four of these are concerned with building and packaging the
application, or contain data files that are not part of the application itself.
Sources and Resources
---------------------
The ``src`` directory is where we will start to explore how the application is
put together. It contains a collection of files and an ``images`` directory.
......@@ -34,3 +37,6 @@ Name Description
The ``meson.build`` file describes the build rules for the program -- we will
look at these later in :ref:`App_Resources_tutorial_building`.
Next, we will look at the ``app_resources.gresource.xml`` file and how
resources are described.
......@@ -13,12 +13,12 @@ that describes the resources to be included with the application.
The Resource Description
------------------------
The ``app_resources.gresource.xml`` file is a resource description file that
will be compiled by the build system to produce the ``app_resources.gresource``
resource bundle file. This file is then packaged with the application and can
be loaded at run-time.
The ``app_resources.gresource.xml`` file is an XML resource description file
that will be compiled by the build system to produce the
``app_resources.gresource`` resource bundle file. This file is then packaged
with the application and can be loaded at run-time.
The file itself provides a manifest of the data files to be included in the
The XML file itself provides a manifest of the data files to be included in the
resource bundle.
.. literalinclude:: app/src/app_resources.gresource.xml
......@@ -43,8 +43,8 @@ structure:
* **picture.svg**
Because the file is specified as ``images/picture.svg`` in the description, an
``images`` directory is included in the directory structure contained in the
resource bundle.
``images`` directory will be included in the virtual directory structure
contained in the ``app_resources.gresource`` resource bundle file.
Accessing Resources
-------------------
......
.. _App_Resources_tutorial_src:
Source Code
===========
Source Files
============
.. contents::
:local:
......@@ -49,8 +49,7 @@ module, which provides a Python interface to the GNOME libraries:
:end-at: repository
When importing the ``Gtk`` module, it is important to specify the version of
the API that will be used. Version 3.0 is the default in many environments, but
it is good practice to be explicit about the version in use.
the API that will be used.
Application Class
~~~~~~~~~~~~~~~~~
......@@ -74,9 +73,6 @@ correctly:
2. It calls the ``GLib.set_application_name`` function to set a user-readable
application name that will be localized if translations are available.
It is not necessary to know what these things do. We just need to ensure that
they are done in this method.
When the application is run, the ``do_active`` method of the ``Application``
class is called. This is something that we need to implement if we want the
application to do something. In this case, we create a window and give it an
......@@ -136,14 +132,15 @@ system. These constants are inserted into the template to replace the
appended to the list of directories that Python uses to find modules.
The second part of the file contains code to load the resources from the
``app_resources.gresource`` resource bundle file and register it so that it can
be used throughout the application:
``app_resources.gresource`` resource bundle file, using a function from the
``Gio`` module. It then registers the resources so that they can be used
throughout the application:
.. literalinclude:: app/src/app-resources.in
:start-at: __main__
Finally, the main module for the application is imported and the ``main``
function is run.
function is run. When this function returns, the application will exit.
Summary
-------
......
......@@ -7,7 +7,7 @@
import sys
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gio, GLib, Gtk
from gi.repository import GLib, Gtk
class Application(Gtk.Application):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment