Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/exercises/en/Exercise20.activity/exercise20.py
diff options
context:
space:
mode:
Diffstat (limited to 'exercises/en/Exercise20.activity/exercise20.py')
-rw-r--r--exercises/en/Exercise20.activity/exercise20.py76
1 files changed, 76 insertions, 0 deletions
diff --git a/exercises/en/Exercise20.activity/exercise20.py b/exercises/en/Exercise20.activity/exercise20.py
new file mode 100644
index 0000000..766f453
--- /dev/null
+++ b/exercises/en/Exercise20.activity/exercise20.py
@@ -0,0 +1,76 @@
+# coding=utf-8
+
+"""Package a Sugar activity to produce a bundle.
+
+Below is a simple Sugar activity which displays a static image. It is very
+boring, but does not need changing. In this exercise, you must add the relevant
+files to git and then build a bundle for the activity and install it on a
+physical XO laptop.
+
+Before packaging the activity, an icon needs to be created.
+
+ 1. Open Inkscape and create a new 48×48 pixel icon (‘icon_48x48’ template).
+ 2. Draw the icon, using only a single stroke colour and a single background
+ colour. Save it as activity/activity.svg.
+ 3. Open the created SVG file with a text editor and replace the stroke colours
+ as described in the ‘Create An Icon’ here:
+ http://en.flossmanuals.net/make-your-own-sugar-activities/package-the-activity/
+ 4. Execute the following commands in a terminal open in the
+ Exercise20.activity/ directory. They will add the relevant files to git:
+ git init
+ git status
+ git add .gitignore exercise20.py setup.py images/logonew2.png
+ git add activity/activity.info
+ git add activity/activity.svg
+ git status
+ git commit
+ They create a new git repository in the current directory, check its
+ status, add the required files to the repository, check its status again
+ to ensure we don’t commit anything we don’t mean to, then commit the new
+ files and changes to the repository.
+
+ The .gitignore file is a special file which lists files that git shouldn’t
+ allow you to add to the repository, and which will be hidden from the
+ output of `git status`.
+ 5. Run ‘./setup.py dist_xo’ to build an XO bundle.
+ 6. Copy the dist/Exercise20-1.xo file to a USB stick and install it on a
+ physical XO laptop.
+"""
+
+from gi.repository import Gtk
+from sugar3.activity import activity, widgets
+from sugar3.graphics.toolbarbox import ToolbarBox
+import os
+
+
+class Exercise20Activity(activity.Activity):
+ """A simple window which displays a static image."""
+ def __init__(self, handle):
+ super(Exercise20Activity, self).__init__(handle)
+
+ # Create the standard activity toolbox.
+ toolbar_box = ToolbarBox()
+ self.set_toolbar_box(toolbar_box)
+ toolbar_box.show()
+
+ main_toolbar = toolbar_box.toolbar
+
+ activity_toolbar_button = widgets.ActivityToolbarButton(self)
+ main_toolbar.insert(activity_toolbar_button, 0)
+ activity_toolbar_button.show()
+
+ stop_button = widgets.StopButton(self)
+ stop_button.show()
+ main_toolbar.insert(stop_button, -1)
+
+ # Add an image to the window.
+ box = Gtk.Box()
+ box.show()
+ self.set_canvas(box)
+
+ image = Gtk.Image()
+ filename = os.path.join(os.path.dirname(__file__),
+ 'images', 'logonew2.png')
+ image.set_from_file(filename)
+ image.show()
+ box.pack_start(image, True, True, 8)