Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Aguiar <alanjas@hotmail.com>2012-05-26 22:12:44 (GMT)
committer Alan Aguiar <alanjas@hotmail.com>2012-05-26 22:12:44 (GMT)
commit300859b78031e90e362f143717fe669cedd0c744 (patch)
treeb0641932f0ce7894965ea4d9f3c468662ae5135d
parentf7ea591a5689b88bee40f3f10125494fcd2b29e4 (diff)
add a minimal help how to use
-rwxr-xr-xactivity.py17
-rw-r--r--helpbutton.py88
-rw-r--r--icons/apple.svg56
-rw-r--r--icons/carrot.svg56
-rw-r--r--icons/hay.svg56
-rw-r--r--icons/help-icon.svg14
6 files changed, 285 insertions, 2 deletions
diff --git a/activity.py b/activity.py
index c7de70e..47d466f 100755
--- a/activity.py
+++ b/activity.py
@@ -31,6 +31,8 @@ from sugar.activity.widgets import ActivityToolbarButton
from sugar.graphics.toolbutton import ToolButton
from sugar.activity.widgets import StopButton
+from helpbutton import HelpButton
+
from gettext import gettext as _
import sugargame.canvas
@@ -73,16 +75,27 @@ class Activity(activity.Activity):
toolbar_box.toolbar.insert(separator, -1)
separator.show()
+ self.create_help(toolbar_box.toolbar)
+
stop_button = StopButton(self)
toolbar_box.toolbar.insert(stop_button, -1)
stop_button.show()
+ self.show_all()
+
+ def create_help(self, toolbar):
+ helpitem = HelpButton()
+ toolbar.insert(helpitem, -1)
+ helpitem.show()
+ helpitem.add_paragraph(_('Click in the background to drop an apple or'))
+ helpitem.add_paragraph(_('press A for an apple'), 'apple')
+ helpitem.add_paragraph(_('press C for a carrot'), 'carrot')
+ helpitem.add_paragraph(_('press H for an hay'), 'hay')
+ helpitem.add_paragraph(_('while you moves the mouse'))
def read_file(self, file_path):
- #self.game.read_file(file_path)
pass
def write_file(self, file_path):
- #self.game.write_file(file_path)
pass
diff --git a/helpbutton.py b/helpbutton.py
new file mode 100644
index 0000000..639159d
--- /dev/null
+++ b/helpbutton.py
@@ -0,0 +1,88 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# Copyright (C) 2012, Gonzalo Odiard <godiard@gmail.com>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+# HelpButton widget
+
+from gettext import gettext as _
+
+import gtk
+
+from sugar.graphics.toolbutton import ToolButton
+from sugar.graphics.icon import Icon
+from sugar.graphics import style
+
+
+class HelpButton(gtk.ToolItem):
+
+ def __init__(self, **kwargs):
+ gtk.ToolItem.__init__(self)
+
+ help_button = ToolButton('help-icon')
+ help_button.set_tooltip(_('Help'))
+ self.add(help_button)
+
+ self._palette = help_button.get_palette()
+
+ sw = gtk.ScrolledWindow()
+ sw.set_size_request(int(gtk.gdk.screen_width() / 2.8),
+ gtk.gdk.screen_height() - style.GRID_CELL_SIZE * 3)
+ sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
+
+ self._max_text_width = int(gtk.gdk.screen_width() / 3) - 20
+ self._vbox = gtk.VBox()
+ self._vbox.set_homogeneous(False)
+
+ hbox = gtk.HBox()
+ hbox.pack_start(self._vbox, False, True, 0)
+
+ sw.add_with_viewport(hbox)
+
+ self._palette.set_content(sw)
+ sw.show_all()
+
+ help_button.connect('clicked', self.__help_button_clicked_cb)
+
+ def __help_button_clicked_cb(self, button):
+ self._palette.popup(immediate=True, state=1)
+
+ def add_section(self, section_text):
+ hbox = gtk.HBox()
+ label = gtk.Label()
+ label.set_use_markup(True)
+ label.set_markup('<b>%s</b>' % section_text)
+ label.set_line_wrap(True)
+ label.set_size_request(self._max_text_width, -1)
+ hbox.add(label)
+ hbox.show_all()
+ self._vbox.pack_start(hbox, False, False, padding=5)
+
+ def add_paragraph(self, text, icon=None):
+ hbox = gtk.HBox()
+ label = gtk.Label(text)
+ label.set_justify(gtk.JUSTIFY_LEFT)
+ label.set_line_wrap(True)
+ hbox.add(label)
+ if icon is not None:
+ _icon = Icon(icon_name=icon)
+ hbox.add(_icon)
+ label.set_size_request(self._max_text_width - 20, -1)
+ else:
+ label.set_size_request(self._max_text_width, -1)
+
+ hbox.show_all()
+ self._vbox.pack_start(hbox, False, False, padding=5)
diff --git a/icons/apple.svg b/icons/apple.svg
new file mode 100644
index 0000000..c737a10
--- /dev/null
+++ b/icons/apple.svg
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ version="1.1"
+ width="55px"
+ height="55px"
+ id="svg2"
+ inkscape:version="0.48.3.1 r9886"
+ sodipodi:docname="apple.svg">
+ <metadata
+ id="metadata14">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs12" />
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1366"
+ inkscape:window-height="744"
+ id="namedview10"
+ showgrid="false"
+ inkscape:zoom="4.2909091"
+ inkscape:cx="19.34322"
+ inkscape:cy="27.5"
+ inkscape:window-x="0"
+ inkscape:window-y="24"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="svg2" />
+ <rect
+ style="fill:#ff0000;fill-opacity:1;stroke:#ffffff;stroke-width:0.83597880999999996;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+ id="rect2991"
+ width="11.88436"
+ height="11.88436"
+ x="22.256973"
+ y="22.256973" />
+</svg>
diff --git a/icons/carrot.svg b/icons/carrot.svg
new file mode 100644
index 0000000..264c7bc
--- /dev/null
+++ b/icons/carrot.svg
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ version="1.1"
+ width="55px"
+ height="55px"
+ id="svg2"
+ inkscape:version="0.48.3.1 r9886"
+ sodipodi:docname="carrot.svg">
+ <metadata
+ id="metadata14">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs12" />
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1366"
+ inkscape:window-height="744"
+ id="namedview10"
+ showgrid="false"
+ inkscape:zoom="4.2909091"
+ inkscape:cx="19.34322"
+ inkscape:cy="27.5"
+ inkscape:window-x="0"
+ inkscape:window-y="24"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="svg2" />
+ <rect
+ style="fill:#ff6600;fill-opacity:1;stroke:#ffffff;stroke-width:1.42662287;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+ id="rect2991"
+ width="14.46668"
+ height="28.432203"
+ x="19.34322"
+ y="14.449152" />
+</svg>
diff --git a/icons/hay.svg b/icons/hay.svg
new file mode 100644
index 0000000..78b1bbf
--- /dev/null
+++ b/icons/hay.svg
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ version="1.1"
+ width="55px"
+ height="55px"
+ id="svg2"
+ inkscape:version="0.48.3.1 r9886"
+ sodipodi:docname="hay.svg">
+ <metadata
+ id="metadata14">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs12" />
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1366"
+ inkscape:window-height="744"
+ id="namedview10"
+ showgrid="false"
+ inkscape:zoom="4.2909091"
+ inkscape:cx="19.34322"
+ inkscape:cy="27.5"
+ inkscape:window-x="0"
+ inkscape:window-y="24"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="svg2" />
+ <rect
+ style="fill-opacity:1;stroke:#ffffff;stroke-width:2;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;fill:#a55f17"
+ id="rect2991"
+ width="28.432203"
+ height="28.432203"
+ x="13.283898"
+ y="13.516949" />
+</svg>
diff --git a/icons/help-icon.svg b/icons/help-icon.svg
new file mode 100644
index 0000000..f6c92bf
--- /dev/null
+++ b/icons/help-icon.svg
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="55px" height="55px">
+ <path
+ style="fill:none;stroke:#ffffff;stroke-width:3;stroke-linejoin:round"
+ d="M 48,28 A 20,20 0 1 1 8,28 A 20,20 0 1 1 48,28 z"/>
+ <path
+ style="fill:none;stroke:#ffffff;stroke-width:6;stroke-linecap:round;stroke-linejoin:round"
+ d="M 22,20 C 22,20 25,17 29,17 C 33,17 36,19 36,23 C 36,27 31,29 28,29 L 28,32" />
+ <path
+ style="fill:#ffffff"
+ d="M 25,40
+ a 3,3 0 1 1 6,0
+ a 3,3 0 1 1 -6,0 z" />
+</svg>