|
|
@@ -205,7 +205,9 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
## This is used to store the wx.Application object used when want-wx is
|
|
|
## set or base.startWx() is called.
|
|
|
self.wxApp = None
|
|
|
+ self.wxAppCreated = False
|
|
|
self.tkRoot = None
|
|
|
+ self.tkRootCreated = False
|
|
|
|
|
|
# This is used for syncing multiple PCs in a distributed cluster
|
|
|
try:
|
|
|
@@ -262,6 +264,17 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
random.seed(seed)
|
|
|
#whrandom.seed(seed & 0xff, (seed >> 8) & 0xff, (seed >> 16) & 0xff)
|
|
|
|
|
|
+ # For some reason, wx needs to be initialized before the graphics window
|
|
|
+ if sys.platform == "darwin":
|
|
|
+ if self.config.GetBool("want-wx", 0):
|
|
|
+ import wx
|
|
|
+ self.wxApp = wx.App()
|
|
|
+
|
|
|
+ # Same goes for Tk, which uses a conflicting NSApplication
|
|
|
+ if self.config.GetBool("want-tk", 0):
|
|
|
+ import Pmw
|
|
|
+ self.tkRoot = Pmw.initialise()
|
|
|
+
|
|
|
# Open the default rendering window.
|
|
|
if self.windowType != 'none':
|
|
|
props = WindowProperties.getDefault()
|
|
|
@@ -2804,15 +2817,16 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
updated, but wxPython owns the main loop (which seems to make
|
|
|
it happier than the other way around). """
|
|
|
|
|
|
- if self.wxApp:
|
|
|
+ if self.wxAppCreated:
|
|
|
# Don't do this twice.
|
|
|
return
|
|
|
|
|
|
init_app_for_gui()
|
|
|
|
|
|
import wx
|
|
|
- # Create a new base.wxApp.
|
|
|
- self.wxApp = wx.PySimpleApp(redirect = False)
|
|
|
+ if not self.wxApp:
|
|
|
+ # Create a new base.wxApp.
|
|
|
+ self.wxApp = wx.PySimpleApp(redirect = False)
|
|
|
|
|
|
if ConfigVariableBool('wx-main-loop', True):
|
|
|
# Put wxPython in charge of the main loop. It really
|
|
|
@@ -2847,6 +2861,7 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
return task.again
|
|
|
|
|
|
self.taskMgr.add(wxLoop, 'wxLoop')
|
|
|
+ self.wxAppCreated = True
|
|
|
|
|
|
def __wxTimerCallback(self, event):
|
|
|
if Thread.getCurrentThread().getCurrentTask():
|
|
|
@@ -2881,7 +2896,7 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
updated, but Tkinter owns the main loop (which seems to make
|
|
|
it happier than the other way around). """
|
|
|
|
|
|
- if self.tkRoot:
|
|
|
+ if self.tkRootCreated:
|
|
|
# Don't do this twice.
|
|
|
return
|
|
|
|
|
|
@@ -2889,7 +2904,8 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
import Pmw
|
|
|
|
|
|
# Create a new Tk root.
|
|
|
- self.tkRoot = Pmw.initialise()
|
|
|
+ if not self.tkRoot:
|
|
|
+ self.tkRoot = Pmw.initialise()
|
|
|
builtins.tkroot = self.tkRoot
|
|
|
|
|
|
init_app_for_gui()
|
|
|
@@ -2925,6 +2941,7 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
return task.again
|
|
|
|
|
|
self.taskMgr.add(tkLoop, 'tkLoop')
|
|
|
+ self.tkRootCreated = True
|
|
|
|
|
|
def __tkTimerCallback(self):
|
|
|
if not Thread.getCurrentThread().getCurrentTask():
|