Changed the order that the demo and code pages are created

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28685 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2004-08-07 02:06:25 +00:00
parent fff8475e0c
commit 317a64e59a

View File

@@ -531,7 +531,6 @@ class DemoCodePanel(wx.Panel):
def ActiveModuleChanged(self): def ActiveModuleChanged(self):
self.LoadDemoSource(self.demoModules.GetSource()) self.LoadDemoSource(self.demoModules.GetSource())
self.UpdateControlState() self.UpdateControlState()
self.ReloadDemo()
def LoadDemoSource(self, source): def LoadDemoSource(self, source):
@@ -575,11 +574,12 @@ class DemoCodePanel(wx.Panel):
busy = wx.BusyInfo("Reloading demo module...") busy = wx.BusyInfo("Reloading demo module...")
self.demoModules.SetActive(modSelected) self.demoModules.SetActive(modSelected)
self.ActiveModuleChanged() self.ActiveModuleChanged()
self.ReloadDemo()
def ReloadDemo(self): def ReloadDemo(self):
if self.demoModules.name != __name__: if self.demoModules.name != __name__:
self.mainFrame.RunModule() self.mainFrame.RunModule(False)
def OnCodeModified(self, event): def OnCodeModified(self, event):
@@ -625,6 +625,7 @@ class DemoCodePanel(wx.Panel):
busy = wx.BusyInfo("Reloading demo module...") busy = wx.BusyInfo("Reloading demo module...")
self.demoModules.LoadFromFile(modModified, modifiedFilename) self.demoModules.LoadFromFile(modModified, modifiedFilename)
self.ActiveModuleChanged() self.ActiveModuleChanged()
self.ReloadDemo()
def OnRestore(self, event): # Handles the "Delete Modified" button def OnRestore(self, event): # Handles the "Delete Modified" button
@@ -633,6 +634,7 @@ class DemoCodePanel(wx.Panel):
os.unlink(modifiedFilename) # Delete the modified copy os.unlink(modifiedFilename) # Delete the modified copy
busy = wx.BusyInfo("Reloading demo module...") busy = wx.BusyInfo("Reloading demo module...")
self.ActiveModuleChanged() self.ActiveModuleChanged()
self.ReloadDemo()
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
@@ -709,10 +711,13 @@ class DemoModules:
# load original module # load original module
self.LoadFromFile(modOriginal, GetOriginalFilename(name)) self.LoadFromFile(modOriginal, GetOriginalFilename(name))
self.SetActive(modOriginal)
# load modified module (if one exists) # load modified module (if one exists)
if DoesModifiedExist(name): if DoesModifiedExist(name):
self.LoadFromFile(modModified, GetModifiedFilename(name)) self.LoadFromFile(modModified, GetModifiedFilename(name))
if (modDefault == modModified):
self.SetActive(modModified)
def LoadFromFile(self, modID, filename): def LoadFromFile(self, modID, filename):
@@ -1258,7 +1263,7 @@ class wxPythonDemo(wx.Frame):
if os.path.exists(GetOriginalFilename(demoName)): if os.path.exists(GetOriginalFilename(demoName)):
wx.LogMessage("Loading demo %s.py..." % demoName) wx.LogMessage("Loading demo %s.py..." % demoName)
self.demoModules = DemoModules(demoName) self.demoModules = DemoModules(demoName)
self.LoadDemoSource() self.RunModule(True)
self.tree.Refresh() self.tree.Refresh()
else: else:
self.SetOverview("wxPython", mainOverview) self.SetOverview("wxPython", mainOverview)
@@ -1274,13 +1279,12 @@ class wxPythonDemo(wx.Frame):
self.codePage.LoadDemo(self.demoModules) self.codePage.LoadDemo(self.demoModules)
#--------------------------------------------- #---------------------------------------------
def RunModule(self): def RunModule(self, loadSource):
"""Runs the active module""" """Runs the active module"""
module = self.demoModules.GetActive() module = self.demoModules.GetActive()
self.ShutdownDemoModule() self.ShutdownDemoModule()
overviewText = "" overviewText = ""
prevSelect = -1
# o If the demo returns a window it is placed in a tab. # o If the demo returns a window it is placed in a tab.
# o Otherwise, a placeholder tab is created, informing the user that the # o Otherwise, a placeholder tab is created, informing the user that the
@@ -1292,23 +1296,22 @@ class wxPythonDemo(wx.Frame):
if hasattr(module, "overview"): if hasattr(module, "overview"):
overviewText = module.overview overviewText = module.overview
# in case runTest is modal, make sure things look right
# before it starts...
prevSelect = self.UpdateNotebook()
wx.YieldIfNeeded()
try: try:
self.demoPage = module.runTest(self, self.nb, self) self.demoPage = module.runTest(self, self.nb, self)
if self.demoPage is None: if self.demoPage is None:
self.demoPage = ReloadDemoPanel(self.nb, self.codePage, self) self.demoPage = ReloadDemoPanel(self.nb, self.codePage, self)
except: except:
self.demoPage = DemoErrorPanel(self.nb, self.codePage, DemoError(sys.exc_info()), self) self.demoPage = DemoErrorPanel(self.nb, self.codePage,
DemoError(sys.exc_info()), self)
else: else:
# There was a previous error in compiling or exec-ing # There was a previous error in compiling or exec-ing
self.demoPage = DemoErrorPanel(self.nb, self.codePage, self.demoModules.GetErrorInfo(), self) self.demoPage = DemoErrorPanel(self.nb, self.codePage,
self.demoModules.GetErrorInfo(), self)
if loadSource:
self.LoadDemoSource()
self.UpdateNotebook()
self.SetOverview(self.demoModules.name + " Overview", overviewText) self.SetOverview(self.demoModules.name + " Overview", overviewText)
self.UpdateNotebook(prevSelect)
#--------------------------------------------- #---------------------------------------------
def ShutdownDemoModule(self): def ShutdownDemoModule(self):
@@ -1336,23 +1339,12 @@ class wxPythonDemo(wx.Frame):
if page: if page:
if not pageExists: if not pageExists:
# Add a new page # Add a new page
# panel = wx.Panel(nb, -1)
# page.Reparent(panel)
# panel.page = page
# nb.AddPage(panel, pageText)
nb.AddPage(page, pageText) nb.AddPage(page, pageText)
if debug: wx.LogMessage("DBG: ADDED %s" % pageText) if debug: wx.LogMessage("DBG: ADDED %s" % pageText)
else: else:
# if nb.GetPage(pagePos).page != page:
if nb.GetPage(pagePos) != page: if nb.GetPage(pagePos) != page:
# Reload an existing page # Reload an existing page
nb.Freeze() nb.Freeze()
# panel = nb.GetPage(pagePos)
# panel.page = page
# page.Reparent(panel)
nb.DeletePage(pagePos) nb.DeletePage(pagePos)
nb.InsertPage(pagePos, page, pageText) nb.InsertPage(pagePos, page, pageText)
nb.Thaw() nb.Thaw()
@@ -1376,8 +1368,6 @@ class wxPythonDemo(wx.Frame):
if select >= 0 and select < nb.GetPageCount(): if select >= 0 and select < nb.GetPageCount():
nb.SetSelection(select) nb.SetSelection(select)
return select
#--------------------------------------------- #---------------------------------------------
def SetOverview(self, name, text): def SetOverview(self, name, text):
self.curOverview = text self.curOverview = text