Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/activity.py
diff options
context:
space:
mode:
authorGary Martin <gary@garycmartin.com>2009-06-21 19:21:20 (GMT)
committer Gary Martin <gary@garycmartin.com>2009-06-21 19:21:20 (GMT)
commit6008d3e6a30eb1686ee58f0971cc69200f97a141 (patch)
tree2a1dfe2fd402d2728846f644dc0aa19b4a891917 /activity.py
parent59ad82a14a1500b957fd397a7807270b9ebc9e65 (diff)
Added stop/play button to toolbar.
Diffstat (limited to 'activity.py')
-rw-r--r--activity.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/activity.py b/activity.py
index edf0d8d..00161c9 100644
--- a/activity.py
+++ b/activity.py
@@ -2,6 +2,7 @@ import tools
import olpcgames
import pygame
from sugar.graphics.radiotoolbutton import RadioToolButton
+from sugar.graphics.toolbutton import ToolButton
from sugar.activity import activity
from gettext import gettext as _
import gtk
@@ -23,6 +24,19 @@ class PhysicsActivity(olpcgames.PyGameActivity):
# make a 'create' toolbar
create_toolbar = gtk.Toolbar()
+ # stop/play button
+ self.stop_play_state = True
+ self.stop_play = ToolButton('media-playback-stop')
+ self.stop_play.set_tooltip(_('Stop'))
+ self.stop_play.set_accelerator(_('space'))
+ self.stop_play.connect('clicked', self.stop_play_cb)
+ create_toolbar.insert(self.stop_play, 0)
+ self.stop_play.show()
+
+ separator = gtk.SeparatorToolItem()
+ create_toolbar.insert(separator, 1)
+ separator.show()
+
# make + add the component buttons
self.radioList = {}
firstButton = None
@@ -49,5 +63,16 @@ class PhysicsActivity(olpcgames.PyGameActivity):
toolbox.set_current_toolbar(1)
return activity_toolbar
+ def stop_play_cb(self, button):
+ pygame.event.post(olpcgames.eventwrap.Event(pygame.KEYDOWN, key=pygame.K_SPACE))
+ self.stop_play_state = not self.stop_play_state
+ # Update button
+ if self.stop_play_state:
+ self.stop_play.set_icon('media-playback-stop')
+ self.stop_play.set_tooltip(_('Stop'))
+ else:
+ self.stop_play.set_icon('media-playback-start')
+ self.stop_play.set_tooltip(_('Start'))
+
def radioClicked(self,button):
pygame.event.post(olpcgames.eventwrap.Event(pygame.USEREVENT, action=self.radioList[button])) \ No newline at end of file