From 4289189381d3f9e59cf656e89f395d58fc8ab53a Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 16 Jul 2008 19:08:20 +0000 Subject: Merge branch 'master' of git+ssh://bjordan@dev.laptop.org/git/activities/physics --- diff --git a/activity.py b/activity.py index 1d0cda7..b0918dd 100644 --- a/activity.py +++ b/activity.py @@ -23,14 +23,9 @@ class PhysicsActivity(olpcgames.PyGameActivity): # make a 'create' toolbar create_toolbar = gtk.Toolbar() - # get a list of all component classes - componentsList = tools.local_classes - componentsList.remove(tools.Tool) - #hack (For now) - componentsList.remove(pygame.Rect) # make + add the component buttons self.radioList = {} - for c in componentsList: + for c in tools.allTools: button = RadioToolButton(named_icon=c.icon) button.set_tooltip(_(c.toolTip)) button.connect('clicked',self.radioClicked) diff --git a/tools.py b/tools.py index 6df93c7..38b3cd6 100644 --- a/tools.py +++ b/tools.py @@ -6,6 +6,7 @@ import pygame from pygame.locals import * from helpers import * +from inspect import getmro # tools that can be used superlcass class Tool(object): name = "Tool" @@ -394,9 +395,13 @@ class JoystickTool(Tool): self.vertices = None -def list_local_classes(): +def getAllTools(): this_mod = __import__(__name__) - return [val for val in this_mod.__dict__.values() - if isinstance(val, type)] + all = [val for val in this_mod.__dict__.values() if isinstance(val, type)] + allTools = [] + for a in all: + if getmro(a).__contains__(Tool) and a!= Tool: allTools.append(a) + return allTools + -local_classes = list_local_classes() +allTools = getAllTools() -- cgit v0.9.1