Browse Source

*** empty log message ***

David Rose 25 years ago
parent
commit
22c2a719c0
2 changed files with 31 additions and 3 deletions
  1. 7 3
      direct/src/gui/Button.py
  2. 24 0
      direct/src/task/Task.py

+ 7 - 3
direct/src/gui/Button.py

@@ -3,7 +3,6 @@ from DirectObject import *
 import GuiManager
 import GuiLabel
 import GuiButton
-import Vec3
 
 guiMgr = GuiManager.GuiManager.getPtr(base.win, base.mak.node(), base.renderGui.node())
 font = loader.loadModelNode("phase_3/models/fonts/ttf-comic")
@@ -88,8 +87,13 @@ class Button(DirectObject):
         self.button.unmanage()
         self.managed = 0
         
-    def setPos(self, x, y):
-        v3 = Vec3.Vec3(x, 0., y)
+    def setPos(self, x, y, node = None):
+        if node == None:
+            v3 = Vec3(x, 0., y)
+        else:
+            mat = node.getMat(base.render2d)
+            v3 = Vec3(mat.xformPoint(Point3(x, 0., y)))
+            
         self.button.setPos(v3)
 
     def setScale(self, scale):

+ 24 - 0
direct/src/task/Task.py

@@ -3,6 +3,7 @@ from libpandaexpressModules import *
 from DirectNotify import *
 from PythonUtil import *
 import time
+import fnmatch
 
 exit = -1
 done = 0
@@ -300,6 +301,29 @@ class TaskManager:
         # Return the number of tasks removed
         return len(removedTasks)
 
+    def removeTasksMatching(self, taskPattern):
+        """removeTasksMatching(self, string taskPattern)
+
+        Removes tasks whose names match the pattern, which can include
+        standard shell globbing characters like *, ?, and [].
+
+        """
+        
+        TaskManager.notify.debug('removing tasks matching: ' + taskPattern)
+        removedTasks = []
+
+        # Find the tasks that match by name and make a list of them
+        for task in self.taskList:
+            if (fnmatch.fnmatchcase(task.name, taskPattern)):
+                removedTasks.append(task)
+
+        # Now iterate through the tasks we need to remove and remove them
+        for task in removedTasks:
+            self.removeTask(task)
+
+        # Return the number of tasks removed
+        return len(removedTasks)
+
     def step(self):
         TaskManager.notify.debug('step')
         self.currentTime, self.currentFrame = getTimeFrame()