mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 00:32:57 -04:00
Remove dependency on tkpanels and tkwidgets modules when building .p3d package
This commit is contained in:
parent
d3885b665e
commit
2d6c2c5c6d
@ -1534,8 +1534,10 @@ class Actor(DirectObject, NodePath):
|
||||
|
||||
# actions
|
||||
def animPanel(self):
|
||||
from direct.showbase import TkGlobal
|
||||
from direct.tkpanels import AnimPanel
|
||||
# Don't use a regular import, to prevent ModuleFinder from picking
|
||||
# it up as a dependency when building a .p3d package.
|
||||
import importlib
|
||||
AnimPanel = importlib.import_module('direct.tkpanels.AnimPanel')
|
||||
return AnimPanel.AnimPanel(self)
|
||||
|
||||
def stop(self, animName=None, partName=None):
|
||||
|
@ -111,10 +111,13 @@ class DirectNotify:
|
||||
category.setWarning(1)
|
||||
category.setInfo(1)
|
||||
category.setDebug(1)
|
||||
|
||||
|
||||
def popupControls(self, tl = None):
|
||||
from direct.tkpanels import NotifyPanel
|
||||
# Don't use a regular import, to prevent ModuleFinder from picking
|
||||
# it up as a dependency when building a .p3d package.
|
||||
import importlib
|
||||
NotifyPanel = importlib.import_module('direct.tkpanels.NotifyPanel')
|
||||
NotifyPanel.NotifyPanel(self, tl)
|
||||
|
||||
|
||||
def giveNotify(self,cls):
|
||||
cls.notify = self.newCategory(cls.__name__)
|
||||
|
@ -58,13 +58,17 @@ def popupControls(self, tl = None):
|
||||
"""
|
||||
Popup control panel for interval.
|
||||
"""
|
||||
from direct.showbase.TkGlobal import Toplevel, Frame, Button, LEFT, X, Pmw
|
||||
import math
|
||||
from direct.tkwidgets import EntryScale
|
||||
# Don't use a regular import, to prevent ModuleFinder from picking
|
||||
# it up as a dependency when building a .p3d package.
|
||||
import importlib
|
||||
EntryScale = importlib.import_module('direct.tkwidgets.EntryScale')
|
||||
Tkinter = importlib.import_module('Tkinter')
|
||||
|
||||
if tl == None:
|
||||
tl = Toplevel()
|
||||
tl = Tkinter.Toplevel()
|
||||
tl.title('Interval Controls')
|
||||
outerFrame = Frame(tl)
|
||||
outerFrame = Tkinter.Frame(tl)
|
||||
def entryScaleCommand(t, s=self):
|
||||
s.setT(t)
|
||||
s.pause()
|
||||
@ -73,8 +77,8 @@ def popupControls(self, tl = None):
|
||||
min = 0, max = math.floor(self.getDuration() * 100) / 100,
|
||||
command = entryScaleCommand)
|
||||
es.set(self.getT(), fCommand = 0)
|
||||
es.pack(expand = 1, fill = X)
|
||||
bf = Frame(outerFrame)
|
||||
es.pack(expand = 1, fill = Tkinter.X)
|
||||
bf = Tkinter.Frame(outerFrame)
|
||||
# Jump to start and end
|
||||
def toStart(s=self, es=es):
|
||||
s.setT(0.0)
|
||||
@ -82,23 +86,23 @@ def popupControls(self, tl = None):
|
||||
def toEnd(s=self):
|
||||
s.setT(s.getDuration())
|
||||
s.pause()
|
||||
jumpToStart = Button(bf, text = '<<', command = toStart)
|
||||
jumpToStart = Tkinter.Button(bf, text = '<<', command = toStart)
|
||||
# Stop/play buttons
|
||||
def doPlay(s=self, es=es):
|
||||
s.resume(es.get())
|
||||
|
||||
stop = Button(bf, text = 'Stop',
|
||||
stop = Tkinter.Button(bf, text = 'Stop',
|
||||
command = lambda s=self: s.pause())
|
||||
play = Button(
|
||||
play = Tkinter.Button(
|
||||
bf, text = 'Play',
|
||||
command = doPlay)
|
||||
jumpToEnd = Button(bf, text = '>>', command = toEnd)
|
||||
jumpToStart.pack(side = LEFT, expand = 1, fill = X)
|
||||
play.pack(side = LEFT, expand = 1, fill = X)
|
||||
stop.pack(side = LEFT, expand = 1, fill = X)
|
||||
jumpToEnd.pack(side = LEFT, expand = 1, fill = X)
|
||||
bf.pack(expand = 1, fill = X)
|
||||
outerFrame.pack(expand = 1, fill = X)
|
||||
jumpToEnd = Tkinter.Button(bf, text = '>>', command = toEnd)
|
||||
jumpToStart.pack(side = Tkinter.LEFT, expand = 1, fill = Tkinter.X)
|
||||
play.pack(side = Tkinter.LEFT, expand = 1, fill = Tkinter.X)
|
||||
stop.pack(side = Tkinter.LEFT, expand = 1, fill = Tkinter.X)
|
||||
jumpToEnd.pack(side = Tkinter.LEFT, expand = 1, fill = Tkinter.X)
|
||||
bf.pack(expand = 1, fill = Tkinter.X)
|
||||
outerFrame.pack(expand = 1, fill = Tkinter.X)
|
||||
# Add function to update slider during setT calls
|
||||
def update(t, es=es):
|
||||
es.set(t, fCommand = 0)
|
||||
|
@ -1079,7 +1079,10 @@ del lerpScaleXYZ
|
||||
#####################################################################
|
||||
def place(self):
|
||||
base.startDirect(fWantTk = 1)
|
||||
from direct.tkpanels import Placer
|
||||
# Don't use a regular import, to prevent ModuleFinder from picking
|
||||
# it up as a dependency when building a .p3d package.
|
||||
import importlib
|
||||
Placer = importlib.import_module('direct.tkpanels.Placer')
|
||||
return Placer.place(self)
|
||||
|
||||
Dtool_funcToMethod(place, NodePath)
|
||||
@ -1087,7 +1090,10 @@ del place
|
||||
#####################################################################
|
||||
def explore(self):
|
||||
base.startDirect(fWantTk = 1)
|
||||
from direct.tkwidgets import SceneGraphExplorer
|
||||
# Don't use a regular import, to prevent ModuleFinder from picking
|
||||
# it up as a dependency when building a .p3d package.
|
||||
import importlib
|
||||
SceneGraphExplorer = importlib.import_module('direct.tkwidgets.SceneGraphExplorer')
|
||||
return SceneGraphExplorer.explore(self)
|
||||
|
||||
Dtool_funcToMethod(explore, NodePath)
|
||||
@ -1095,7 +1101,10 @@ del explore
|
||||
#####################################################################
|
||||
def rgbPanel(self, cb = None):
|
||||
base.startTk()
|
||||
from direct.tkwidgets import Slider
|
||||
# Don't use a regular import, to prevent ModuleFinder from picking
|
||||
# it up as a dependency when building a .p3d package.
|
||||
import importlib
|
||||
Slider = importlib.import_module('direct.tkwidgets.Slider')
|
||||
return Slider.rgbPanel(self, cb)
|
||||
|
||||
Dtool_funcToMethod(rgbPanel, NodePath)
|
||||
|
@ -369,7 +369,10 @@ class ClassicFSM(DirectObject):
|
||||
return 0
|
||||
|
||||
def view(self):
|
||||
from direct.tkpanels import FSMInspector
|
||||
# Don't use a regular import, to prevent ModuleFinder from picking
|
||||
# it up as a dependency when building a .p3d package.
|
||||
import importlib
|
||||
FSMInspector = importlib.import_module('direct.tkpanels.FSMInspector')
|
||||
FSMInspector.FSMInspector(self)
|
||||
|
||||
def isInternalStateInFlux(self):
|
||||
|
@ -443,16 +443,16 @@ class Interval(DirectObject):
|
||||
"""
|
||||
Popup control panel for interval.
|
||||
"""
|
||||
from direct.showbase import TkGlobal
|
||||
import math
|
||||
# I moved this here because Toontown does not ship Tk
|
||||
from Tkinter import Toplevel, Frame, Button, LEFT, X
|
||||
import Pmw
|
||||
from direct.tkwidgets import EntryScale
|
||||
# Don't use a regular import, to prevent ModuleFinder from picking
|
||||
# it up as a dependency when building a .p3d package.
|
||||
import importlib
|
||||
EntryScale = importlib.import_module('direct.tkwidgets.EntryScale')
|
||||
Tkinter = importlib.import_module('Tkinter')
|
||||
|
||||
if tl == None:
|
||||
tl = Toplevel()
|
||||
tl = Tkinter.Toplevel()
|
||||
tl.title('Interval Controls')
|
||||
outerFrame = Frame(tl)
|
||||
outerFrame = Tkinter.Frame(tl)
|
||||
def entryScaleCommand(t, s=self):
|
||||
s.setT(t)
|
||||
s.pause()
|
||||
@ -461,8 +461,8 @@ class Interval(DirectObject):
|
||||
min = 0, max = math.floor(self.getDuration() * 100) / 100,
|
||||
command = entryScaleCommand)
|
||||
es.set(self.getT(), fCommand = 0)
|
||||
es.pack(expand = 1, fill = X)
|
||||
bf = Frame(outerFrame)
|
||||
es.pack(expand = 1, fill = Tkinter.X)
|
||||
bf = Tkinter.Frame(outerFrame)
|
||||
# Jump to start and end
|
||||
def toStart(s=self, es=es):
|
||||
s.clearToInitial()
|
||||
@ -472,23 +472,23 @@ class Interval(DirectObject):
|
||||
s.setT(s.getDuration())
|
||||
es.set(s.getDuration(), fCommand = 0)
|
||||
s.pause()
|
||||
jumpToStart = Button(bf, text = '<<', command = toStart)
|
||||
jumpToStart = Tkinter.Button(bf, text = '<<', command = toStart)
|
||||
# Stop/play buttons
|
||||
def doPlay(s=self, es=es):
|
||||
s.resume(es.get())
|
||||
|
||||
stop = Button(bf, text = 'Stop',
|
||||
stop = Tkinter.Button(bf, text = 'Stop',
|
||||
command = lambda s=self: s.pause())
|
||||
play = Button(
|
||||
play = Tkinter.Button(
|
||||
bf, text = 'Play',
|
||||
command = doPlay)
|
||||
jumpToEnd = Button(bf, text = '>>', command = toEnd)
|
||||
jumpToStart.pack(side = LEFT, expand = 1, fill = X)
|
||||
play.pack(side = LEFT, expand = 1, fill = X)
|
||||
stop.pack(side = LEFT, expand = 1, fill = X)
|
||||
jumpToEnd.pack(side = LEFT, expand = 1, fill = X)
|
||||
bf.pack(expand = 1, fill = X)
|
||||
outerFrame.pack(expand = 1, fill = X)
|
||||
jumpToEnd = Tkinter.Button(bf, text = '>>', command = toEnd)
|
||||
jumpToStart.pack(side = Tkinter.LEFT, expand = 1, fill = Tkinter.X)
|
||||
play.pack(side = Tkinter.LEFT, expand = 1, fill = Tkinter.X)
|
||||
stop.pack(side = Tkinter.LEFT, expand = 1, fill = Tkinter.X)
|
||||
jumpToEnd.pack(side = Tkinter.LEFT, expand = 1, fill = Tkinter.X)
|
||||
bf.pack(expand = 1, fill = Tkinter.X)
|
||||
outerFrame.pack(expand = 1, fill = Tkinter.X)
|
||||
# Add function to update slider during setT calls
|
||||
def update(t, es=es):
|
||||
es.set(t, fCommand = 0)
|
||||
|
@ -327,7 +327,10 @@ def adjust(command = None, dim = 1, parent = None, **kw):
|
||||
10.0
|
||||
"""
|
||||
# Make sure we enable Tk
|
||||
from direct.tkwidgets import Valuator
|
||||
# Don't use a regular import, to prevent ModuleFinder from picking
|
||||
# it up as a dependency when building a .p3d package.
|
||||
import importlib
|
||||
Valuator = importlib.import_module('direct.tkwidgets.Valuator')
|
||||
# Set command if specified
|
||||
if command:
|
||||
kw['command'] = lambda x: apply(command, x)
|
||||
|
@ -14,7 +14,10 @@ assert base
|
||||
directNotify.setDconfigLevels()
|
||||
|
||||
def inspect(anObject):
|
||||
from direct.tkpanels import Inspector
|
||||
# Don't use a regular import, to prevent ModuleFinder from picking
|
||||
# it up as a dependency when building a .p3d package.
|
||||
import importlib
|
||||
Inspector = importlib.import_module('direct.tkpanels.Inspector')
|
||||
return Inspector.inspect(anObject)
|
||||
|
||||
import __builtin__
|
||||
|
@ -583,7 +583,10 @@ class TaskManager:
|
||||
return numFound
|
||||
|
||||
def popupControls(self):
|
||||
from direct.tkpanels import TaskManagerPanel
|
||||
# Don't use a regular import, to prevent ModuleFinder from picking
|
||||
# it up as a dependency when building a .p3d package.
|
||||
import importlib
|
||||
TaskManagerPanel = importlib.import_module('direct.tkpanels.TaskManagerPanel')
|
||||
return TaskManagerPanel.TaskManagerPanel(self)
|
||||
|
||||
def getProfileSession(self, name=None):
|
||||
|
Loading…
x
Reference in New Issue
Block a user