Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activity.py7
-rw-r--r--tools.py13
2 files changed, 10 insertions, 10 deletions
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()