blob: b0918ddd65819ca89e8171d96c25d7b0ef1d45c9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
import tools
import olpcgames
import pygame
from sugar.graphics.radiotoolbutton import RadioToolButton
from sugar.activity import activity
from gettext import gettext as _
import gtk
class PhysicsActivity(olpcgames.PyGameActivity):
game_name = 'physics'
game_title = 'Physics'
game_size = None # olpcgame will choose size
# setup the toolbar
def build_toolbar(self):
# make a toolbox
toolbox = activity.ActivityToolbox(self)
# modify the Activity tab
activity_toolbar = toolbox.get_activity_toolbar()
activity_toolbar.share.props.visible = False
self.blocklist = []
# make a 'create' toolbar
create_toolbar = gtk.Toolbar()
# make + add the component buttons
self.radioList = {}
for c in tools.allTools:
button = RadioToolButton(named_icon=c.icon)
button.set_tooltip(_(c.toolTip))
button.connect('clicked',self.radioClicked)
create_toolbar.insert(button,-1)
button.show()
self.radioList[button] = c.name
# add the toolbars to the toolbox
toolbox.add_toolbar("Create",create_toolbar)
create_toolbar.show()
toolbox.show()
self.set_toolbox(toolbox)
toolbox.set_current_toolbar(1)
return activity_toolbar
def radioClicked(self,button):
pygame.event.post(olpcgames.eventwrap.Event(pygame.USEREVENT, action=self.radioList[button]))
|