Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bernabé <laurent.bernabe@gmail.com>2013-09-25 18:10:04 (GMT)
committer Laurent Bernabé <laurent.bernabe@gmail.com>2013-09-25 18:10:04 (GMT)
commitf04c2fd333c08919a1a1ae8309f9ebb16347474a (patch)
tree46af874b9a7dc7666bd225e5c4a58d6b3bcccc9f
parent6b2667cd1bf4fef8db3a8b4fa7cf6fec558fe336 (diff)
Third patch, given by Alan Jhonn Aguiar Schwyn
-rw-r--r--activity.py32
-rw-r--r--main_game.py8
2 files changed, 36 insertions, 4 deletions
diff --git a/activity.py b/activity.py
index 63faeff..f888b8d 100644
--- a/activity.py
+++ b/activity.py
@@ -3,10 +3,15 @@
import sugargame
import sugargame.canvas
-from sugar.activity import activity
+from gi.repository import Gtk
-import main
+from sugar3.activity import activity
+from sugar3.graphics.toolbarbox import ToolbarBox
+from sugar3.activity.widgets import ActivityToolbarButton
+from sugar3.graphics.toolbutton import ToolButton
+from sugar3.activity.widgets import StopButton
+import main
class Activity(activity.Activity):
@@ -14,14 +19,35 @@ class Activity(activity.Activity):
activity.Activity.__init__(self, handle)
self.max_participants = 1
+ self.build_toolbar()
self._act = main.Game()
self._pygamecanvas = sugargame.canvas.PygameCanvas(self)
self.set_canvas(self._pygamecanvas)
self._pygamecanvas.grab_focus()
self._pygamecanvas.run_pygame(self._act.run)
+ def build_toolbar(self):
+ toolbar_box = ToolbarBox()
+ self.set_toolbar_box(toolbar_box)
+ toolbar_box.show()
+
+ activity_button = ActivityToolbarButton(self)
+ toolbar_box.toolbar.insert(activity_button, -1)
+ activity_button.show()
+
+ # Blank space (separator) and Stop button at the end
+ separator = Gtk.SeparatorToolItem()
+ separator.props.draw = False
+ separator.set_expand(True)
+ toolbar_box.toolbar.insert(separator, -1)
+ separator.show()
+
+ stop_button = StopButton(self)
+ toolbar_box.toolbar.insert(stop_button, -1)
+ stop_button.show()
+
def read_file(self, file_path):
pass
-
+
def write_file(self, file_path):
pass
diff --git a/main_game.py b/main_game.py
index 740c0cb..c899de5 100644
--- a/main_game.py
+++ b/main_game.py
@@ -78,6 +78,7 @@ def play_game(time_seconds, operations_config):
else:
size = screen.get_size()
+
clock = pygame.time.Clock()
font = pygame.font.Font(None, 16)
#font = PangoFont(family='Helvetica', size=16, bold=True)
@@ -154,12 +155,17 @@ def play_game(time_seconds, operations_config):
end_txt = "Success !"
else:
end_txt = "Failure !"
- end_txt_surface = end_font.render(end_txt, 1,
+ end_txt_surface = end_font.render(end_txt,1,
BLUE, RED)
screen.blit(end_txt_surface, END_TXT_POS)
+
+ while Gtk.events_pending():
+ Gtk.main_iteration()
+
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
exit()
elif event.type == USEREVENT + 2:
show_status = not show_status
+