Toolbar in OLPCGames
Ross Andrews
lists at geekfu.org
Thu Dec 27 22:46:34 EST 2007
On Dec 27, 2007, at 8:20 PM, Asheesh Laroia wrote:
> On Thu, 27 Dec 2007, Ross Andrews wrote:
>
>> I have been banging my head against this for a while, and I am lost.
>>
>> I've got a program made using OLPCGames. I am trying to add a toolbar
>> to it with some custom buttons, and I can't find any example code on
>> the wiki that works. I've looked at Implode, an activity kinda like
>> mine, but it isn't using Pygame, and I can't follow the part of the
>> code that (I think) does the toolbar (it also looks totally unlike
>> the
>> example code).
>
> Try looking at the web browser activity. I found its webtoolbar
> module very self-explanatory.
>
> -- Asheesh.
>
> --
> The older a man gets, the farther he had to walk to school as a boy.
It is much simpler than the Implode code, but I still have some
problems. Here is what I have in activity.py:
class Activity(olpcgames.PyGameActivity):
"""Your Sugar activity"""
game_name = 'run'
game_title = _('Game Of Life')
game_size = None
def __init__(self,handle):
activity.Activity.__init__(self, handle)
mytoolbox = gtk.Toolbar()
helpbut = ToolButton('activity')#Stock help icon
helpbut.set_tooltip(_("Foo!"))
helpbut.connect('clicked', self.help_button_pressed)
mytoolbox.insert(helpbut, -1)
helpbut.show()
self.set_toolbox(mytoolbox)
mytoolbox.show()
def help_button_pressed(self, button):
None
This makes a blank window with a toolbar, the toolbar does indeed have
a single icon with a picture of a hammer on it (the contents of
activity.svg). But, nothing else happens! It seems that by overriding
__init__ I've broken whatever magic started up Pygame and ran the code
in run.py.
More information about the Devel
mailing list