*** empty log message ***
This commit is contained in:
parent
c5681c503a
commit
b02c99f622
|
|
@ -26,7 +26,10 @@ class DirectSession(PandaObject):
|
|||
# These come early since they are used later on
|
||||
self.group = render.attachNewNode('DIRECT')
|
||||
# Set priority to 100 so it always is textured
|
||||
self.font = loader.loadFont("models/fonts/Comic", 100)
|
||||
# Call class method to avoid conflict with ToontownLoader
|
||||
self.font = Loader.Loader.loadFont(loader,
|
||||
"models/fonts/Comic",
|
||||
priority = 100)
|
||||
self.fEnabled = 0
|
||||
self.drList = DisplayRegionList()
|
||||
self.iRayList = map(lambda x: x.iRay, self.drList)
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ class Interval(DirectObject):
|
|||
import EntryScale
|
||||
if tl == None:
|
||||
tl = Toplevel()
|
||||
tl.title(' Interval Controls')
|
||||
tl.title('Interval Controls')
|
||||
outerFrame = Frame(tl)
|
||||
self.es = es = EntryScale.EntryScale(
|
||||
outerFrame, text = self.getName(),
|
||||
|
|
|
|||
|
|
@ -29,7 +29,11 @@ def getTimeFrame():
|
|||
|
||||
|
||||
class Task:
|
||||
count = 0
|
||||
def __init__(self, callback, priority = 0):
|
||||
# Unique ID for each task
|
||||
self.id = Task.count
|
||||
Task.count += 1
|
||||
self.__call__ = callback
|
||||
self._priority = priority
|
||||
self.uponDeath = None
|
||||
|
|
@ -264,10 +268,15 @@ class TaskManager:
|
|||
TaskManager.notify = directNotify.newCategory("TaskManager")
|
||||
self.taskTimerVerbose = 0
|
||||
self.pStatsTasks = 0
|
||||
self.fVerbose = 0
|
||||
|
||||
def stepping(value):
|
||||
def stepping(self, value):
|
||||
self.stepping = value
|
||||
|
||||
def setVerbose(self, value):
|
||||
self.fVerbose = value
|
||||
messenger.send('TaskManager-setVerbose', sentArgs = [value])
|
||||
|
||||
def spawnMethodNamed(self, func, name):
|
||||
task = Task(func)
|
||||
return self.spawnTaskNamed(task, name)
|
||||
|
|
@ -300,6 +309,11 @@ class TaskManager:
|
|||
if hyphen >= 0:
|
||||
name = name[0:hyphen]
|
||||
task.setupPStats(name)
|
||||
|
||||
if self.fVerbose:
|
||||
# Alert the world, a new task is born!
|
||||
messenger.send('TaskManager-spawnTask',
|
||||
sentArgs = [task, name, index])
|
||||
|
||||
return task
|
||||
|
||||
|
|
@ -322,6 +336,10 @@ class TaskManager:
|
|||
self.taskList.remove(task)
|
||||
if task.uponDeath:
|
||||
task.uponDeath(task)
|
||||
if self.fVerbose:
|
||||
# We regret to announce...
|
||||
messenger.send('TaskManager-removeTask',
|
||||
sentArgs = [task, task.name])
|
||||
|
||||
def removeTasksNamed(self, taskName):
|
||||
if TaskManager.notify.getDebug():
|
||||
|
|
@ -501,6 +519,10 @@ class TaskManager:
|
|||
+ '\n')
|
||||
return str
|
||||
|
||||
def popupControls(self):
|
||||
from TaskManagerPanel import *
|
||||
return TaskManagerPanel(self)
|
||||
|
||||
|
||||
"""
|
||||
import Task
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import Floater
|
|||
import EntryScale
|
||||
import VectorWidgets
|
||||
import SceneGraphExplorer
|
||||
from TaskManagerPanel import TaskManagerWidget
|
||||
|
||||
"""
|
||||
Possible to add:
|
||||
|
|
@ -160,6 +161,7 @@ class DirectSessionPanel(AppShell):
|
|||
lightsPage = notebook.add('Lights')
|
||||
gridPage = notebook.add('Grid')
|
||||
devicePage = notebook.add('Devices')
|
||||
tasksPage = notebook.add('Tasks')
|
||||
scenePage = notebook.add('Scene')
|
||||
# Put this here so it isn't called right away
|
||||
notebook['raisecommand'] = self.updateInfo
|
||||
|
|
@ -564,6 +566,11 @@ class DirectSessionPanel(AppShell):
|
|||
self.jbHprSF.pack(fill = X, expand = 0)
|
||||
self.bind(self.jbHprSF, 'Set joybox HPR speed multiplier')
|
||||
|
||||
## TASKS PAGE ##
|
||||
Label(tasksPage, text = 'TASKS',
|
||||
font=('MSSansSerif', 14, 'bold')).pack(expand = 0)
|
||||
self.taskMgrPanel = TaskManagerWidget(tasksPage, taskMgr)
|
||||
|
||||
notebook.setnaturalsize()
|
||||
|
||||
framePane.pack(expand = 1, fill = BOTH)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,188 @@
|
|||
from AppShell import *
|
||||
|
||||
|
||||
class TaskManagerPanel(AppShell):
|
||||
# Override class variables here
|
||||
appname = 'TaskManager Panel'
|
||||
frameWidth = 300
|
||||
frameHeight = 400
|
||||
usecommandarea = 0
|
||||
usestatusarea = 0
|
||||
|
||||
def __init__(self, taskMgr, parent = None, **kw):
|
||||
INITOPT = Pmw.INITOPT
|
||||
optiondefs = (
|
||||
('title', self.appname, None),
|
||||
('taskMgr', None, None)
|
||||
)
|
||||
self.defineoptions(kw, optiondefs)
|
||||
|
||||
# Call superclass initialization function
|
||||
AppShell.__init__(self, parent = parent)
|
||||
|
||||
self.initialiseoptions(TaskManagerPanel)
|
||||
|
||||
def createInterface(self):
|
||||
# FILE MENU
|
||||
# Get a handle on the file menu so commands can be inserted
|
||||
# before quit item
|
||||
self.taskMgrWidget = TaskManagerWidget(
|
||||
self.interior(), self['taskMgr'])
|
||||
|
||||
|
||||
def onDestroy(self, event):
|
||||
self.ignore('TaskManager-setVerbose')
|
||||
self.taskMgrWidget.onDestroy()
|
||||
|
||||
class TaskManagerWidget(PandaObject):
|
||||
"""
|
||||
TaskManagerWidget class: this class contains methods for creating
|
||||
a panel to control taskManager tasks.
|
||||
"""
|
||||
|
||||
def __init__(self, parent, taskMgr):
|
||||
"""__init__(self)
|
||||
TaskManagerWidget class pops up a control panel to view/delete
|
||||
tasks managed by the taskManager.
|
||||
"""
|
||||
# Make sure TK mainloop is running
|
||||
from TkGlobal import *
|
||||
# Record parent (used by ok cancel dialog boxes)
|
||||
self.parent = parent
|
||||
# Record taskManager
|
||||
self.taskMgr = taskMgr
|
||||
# Enable sending of spawn and remove messages
|
||||
self.taskMgr.setVerbose(1)
|
||||
# Init current task
|
||||
self.currentTask = None
|
||||
self.__taskDict = {}
|
||||
|
||||
# Create widgets
|
||||
# Create a listbox
|
||||
self.taskListBox = Pmw.ScrolledListBox(
|
||||
parent,
|
||||
labelpos = NW, label_text = 'Tasks:',
|
||||
label_font=('MSSansSerif', 10, 'bold'),
|
||||
listbox_takefocus = 1,
|
||||
items = [],
|
||||
selectioncommand = self.setCurrentTask)
|
||||
self.taskListBox.pack(expand = 1, fill = BOTH)
|
||||
|
||||
# Controls Frame
|
||||
controlsFrame = Frame(parent)
|
||||
self.removeButton = Button(controlsFrame, text = 'Remove Task',
|
||||
command = self.removeCurrentTask)
|
||||
#self.removeButton.pack(expand = 1, fill = X, side = LEFT)
|
||||
self.removeButton.grid(row = 0, col = 0, sticky = EW)
|
||||
self.removeMatchingButton = Button(controlsFrame,
|
||||
text = 'Remove Matching Tasks',
|
||||
command = self.removeMatchingTasks)
|
||||
#self.removeMatchingButton.pack(expand = 1, fill = X, side = LEFT)
|
||||
self.removeMatchingButton.grid(row = 0, col = 1, sticky = EW)
|
||||
|
||||
self.taskMgrVerbose = IntVar()
|
||||
self.taskMgrVerbose.set(1)
|
||||
self.update = Button(
|
||||
controlsFrame,
|
||||
text = 'Update',
|
||||
command = self.updateTaskListBox)
|
||||
#self.update.pack(expand = 1, fill = X, side = LEFT)
|
||||
self.update.grid(row = 1, col = 0, sticky = EW)
|
||||
self.dynamicUpdate = Checkbutton(
|
||||
controlsFrame,
|
||||
text = 'Dynamic Update',
|
||||
variable = self.taskMgrVerbose,
|
||||
command = self.toggleTaskMgrVerbose)
|
||||
#self.dynamicUpdate.pack(expand = 1, fill = X, side = LEFT)
|
||||
self.dynamicUpdate.grid(row = 1, col = 1, sticky = EW)
|
||||
# Pack frames
|
||||
controlsFrame.pack(fill = X)
|
||||
controlsFrame.grid_columnconfigure(0, weight = 1)
|
||||
controlsFrame.grid_columnconfigure(1, weight = 1)
|
||||
|
||||
# Add hook to spawnTaskEvents
|
||||
self.accept('TaskManager-spawnTask', self.spawnTaskHook)
|
||||
self.accept('TaskManager-removeTask', self.removeTaskHook)
|
||||
self.accept('TaskManager-setVerbose', self.updateTaskMgrVerbose)
|
||||
# Get listbox
|
||||
listbox = self.taskListBox.component('listbox')
|
||||
# Bind updates to arrow buttons
|
||||
listbox.bind('<KeyRelease-Up>', self.setCurrentTask)
|
||||
listbox.bind('<KeyRelease-Down>', self.setCurrentTask)
|
||||
# And grab focus (to allow keyboard navigation)
|
||||
listbox.focus_set()
|
||||
# Update listbox values
|
||||
self.updateTaskListBox()
|
||||
|
||||
def setCurrentTask(self, event = None):
|
||||
index = int(self.taskListBox.curselection()[0])
|
||||
self.currentTask = self.__taskDict[index]
|
||||
|
||||
def updateTaskListBox(self):
|
||||
# Get a list of task names
|
||||
taskNames = []
|
||||
self.__taskDict = {}
|
||||
count = 0
|
||||
for task in self.taskMgr.taskList:
|
||||
taskNames.append(task.name)
|
||||
self.__taskDict[count] = task
|
||||
count += 1
|
||||
self.taskListBox.setlist(taskNames)
|
||||
# And set current index (so keypresses will start with index 0)
|
||||
self.taskListBox.component('listbox').activate(0)
|
||||
# Select first item
|
||||
self.taskListBox.select_set(0)
|
||||
self.setCurrentTask()
|
||||
|
||||
def toggleTaskMgrVerbose(self):
|
||||
taskMgr.setVerbose(self.taskMgrVerbose.get())
|
||||
if self.taskMgrVerbose.get():
|
||||
self.updateTaskListBox()
|
||||
|
||||
def updateTaskMgrVerbose(self, value):
|
||||
self.taskMgrVerbose.set(value)
|
||||
|
||||
def spawnTaskHook(self, task, name, index):
|
||||
self.updateTaskListBox()
|
||||
|
||||
def removeTaskHook(self, task, name):
|
||||
self.updateTaskListBox()
|
||||
|
||||
def removeCurrentTask(self):
|
||||
if self.currentTask:
|
||||
name = self.currentTask.name
|
||||
ok = 1
|
||||
if ((name == 'dataloop') or
|
||||
(name == 'tkloop') or
|
||||
(name == 'eventManager') or
|
||||
(name == 'igloop')):
|
||||
from tkMessageBox import askokcancel
|
||||
ok = askokcancel('TaskManagerControls',
|
||||
'Remove: %s?' % name,
|
||||
parent = self.parent,
|
||||
default = 'cancel')
|
||||
if ok:
|
||||
self.taskMgr.removeTask(self.currentTask)
|
||||
self.updateTaskListBox()
|
||||
|
||||
def removeMatchingTasks(self):
|
||||
name = self.taskListBox.getcurselection()[0]
|
||||
ok = 1
|
||||
if ((name == 'dataloop') or
|
||||
(name == 'tkloop') or
|
||||
(name == 'eventManager') or
|
||||
(name == 'igloop')):
|
||||
from tkMessageBox import askokcancel
|
||||
ok = askokcancel('TaskManagerControls',
|
||||
'Remove tasks named: %s?' % name,
|
||||
parent = self.parent,
|
||||
default = 'cancel')
|
||||
if ok:
|
||||
self.taskMgr.removeTasksNamed(name)
|
||||
self.updateTaskListBox()
|
||||
|
||||
def onDestroy(self):
|
||||
self.ignore('TaskManager-spawnTask')
|
||||
self.ignore('TaskManager-removeTask')
|
||||
|
||||
|
||||
Loading…
Reference in New Issue