dialog, (but the best thing to do is to just always make a panel with
buttons to launch the dialog...)
Fix the find text to ensure that the found text is visible
Added ability to open a PyShell window that has the app and demo frame
preloaded in the namespace.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28665
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
def ShowPosition(self, pos):
line = self.LineFromPosition(pos)
def ShowPosition(self, pos):
line = self.LineFromPosition(pos)
- self.EnsureVisible(line)
+ #self.EnsureVisible(line)
+ self.GotoLine(line)
def GetLastPosition(self):
return self.GetLength()
def GetLastPosition(self):
return self.GetLength()
# White space
self.SetViewWhiteSpace(False) # Don't view white space
# White space
self.SetViewWhiteSpace(False) # Don't view white space
- # EOL
- #self.SetEOLMode(wx.stc.STC_EOL_CRLF) # Just leave it at the default (autosense)
- self.SetViewEOL(False)
+ # EOL: Since we are loading/saving ourselves, and the
+ # strings will always have \n's in them, set the STC to
+ # edit them that way.
+ self.SetEOLMode(wx.stc.STC_EOL_LF)
+ self.SetViewEOL(False)
+
# No right-edge mode indicator
self.SetEdgeMode(stc.STC_EDGE_NONE)
# No right-edge mode indicator
self.SetEdgeMode(stc.STC_EDGE_NONE)
self.box = wx.BoxSizer(wx.VERTICAL)
self.box.Add(self.controlBox, 0, wx.EXPAND)
self.box = wx.BoxSizer(wx.VERTICAL)
self.box.Add(self.controlBox, 0, wx.EXPAND)
+ self.box.Add(wx.StaticLine(self), 0, wx.EXPAND)
self.box.Add(self.editor, 1, wx.EXPAND)
self.box.Fit(self)
self.box.Add(self.editor, 1, wx.EXPAND)
self.box.Fit(self)
wx.LogMessage("Created directory for modified demos: %s" % GetModifiedDirectory())
# Save
wx.LogMessage("Created directory for modified demos: %s" % GetModifiedDirectory())
# Save
- f = open(modifiedFilename, "w")
+ f = open(modifiedFilename, "wt")
source = self.editor.GetText()
try:
f.write(source)
source = self.editor.GetText()
try:
f.write(source)
def LoadFromFile(self, modID, filename):
self.modules[modID][2] = filename
def LoadFromFile(self, modID, filename):
self.modules[modID][2] = filename
- file = open(filename, "r")
+ file = open(filename, "rt")
self.LoadFromSource(modID, file.read())
file.close()
self.LoadFromSource(modID, file.read())
file.close()
filename = self.modules[modID][2]
try:
filename = self.modules[modID][2]
try:
- file = open(filename, "w")
+ file = open(filename, "wt")
file.write(source)
finally:
file.close()
file.write(source)
finally:
file.close()
self.demoPage = None
self.codePage = None
self.useModified = False
self.demoPage = None
self.codePage = None
self.useModified = False
icon = images.getMondrianIcon()
self.SetIcon(icon)
icon = images.getMondrianIcon()
self.SetIcon(icon)
- helpID = wx.NewId()
- findID = wx.NewId()
- findnextID = wx.NewId()
menu = wx.Menu()
findItem = menu.Append(-1, '&Find\tCtrl-F', 'Find in the Demo Code')
findnextItem = menu.Append(-1, 'Find &Next\tF3', 'Find Next')
menu.AppendSeparator()
menu = wx.Menu()
findItem = menu.Append(-1, '&Find\tCtrl-F', 'Find in the Demo Code')
findnextItem = menu.Append(-1, 'Find &Next\tF3', 'Find Next')
menu.AppendSeparator()
+
+ shellItem = menu.Append(-1, 'Open Py&Shell Window\tF5',
+ 'An interactive interpreter window with the demo app and frame objects in the namesapce')
+ menu.AppendSeparator()
helpItem = menu.Append(-1, '&About\tCtrl-H', 'wxPython RULES!!!')
wx.App_SetMacAboutMenuItemId(helpItem.GetId())
helpItem = menu.Append(-1, '&About\tCtrl-H', 'wxPython RULES!!!')
wx.App_SetMacAboutMenuItemId(helpItem.GetId())
+
+ self.Bind(wx.EVT_MENU, self.OnOpenShellWindow, shellItem)
self.Bind(wx.EVT_MENU, self.OnHelpAbout, helpItem)
self.Bind(wx.EVT_MENU, self.OnHelpFind, findItem)
self.Bind(wx.EVT_MENU, self.OnFindNext, findnextItem)
self.Bind(wx.EVT_MENU, self.OnHelpAbout, helpItem)
self.Bind(wx.EVT_MENU, self.OnHelpFind, findItem)
self.Bind(wx.EVT_MENU, self.OnFindNext, findnextItem)
module = self.demoModules.GetActive()
self.ShutdownDemoModule()
overviewText = ""
module = self.demoModules.GetActive()
self.ShutdownDemoModule()
overviewText = ""
# 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 If the demo returns a window it is placed in a tab.
# o Otherwise, a placeholder tab is created, informing the user that the
if hasattr(module, "overview"):
overviewText = module.overview
if hasattr(module, "overview"):
overviewText = module.overview
- # in case runTest is modal, make sure things look right...
+ # in case runTest is modal, make sure things look right
+ # before it starts...
+ prevSelect = self.UpdateNotebook()
else:
# There was a previous error in compiling or exec-ing
self.demoPage = DemoErrorPanel(self.nb, self.codePage, self.demoModules.GetErrorInfo(), self)
else:
# There was a previous error in compiling or exec-ing
self.demoPage = DemoErrorPanel(self.nb, self.codePage, self.demoModules.GetErrorInfo(), self)
self.SetOverview(self.demoModules.name + " Overview", overviewText)
self.SetOverview(self.demoModules.name + " Overview", overviewText)
+ self.UpdateNotebook(prevSelect)
#---------------------------------------------
def ShutdownDemoModule(self):
#---------------------------------------------
def ShutdownDemoModule(self):
UpdatePage(self.codePage, "Demo Code")
UpdatePage(self.demoPage, "Demo")
UpdatePage(self.codePage, "Demo Code")
UpdatePage(self.demoPage, "Demo")
+ if select >= 0 and select < nb.GetPageCount():
#---------------------------------------------
def SetOverview(self, name, text):
self.curOverview = text
#---------------------------------------------
def SetOverview(self, name, text):
self.curOverview = text
event.GetDialog().Destroy()
event.GetDialog().Destroy()
+ def OnOpenShellWindow(self, evt):
+ if self.shell:
+ # if it already exists then just make sure it's visible
+ s = self.shell
+ if s.IsIconized():
+ s.Iconize(False)
+ s.Raise()
+ else:
+ # Make a PyShell window
+ from wx import py
+ namespace = { 'wx' : wx,
+ 'app' : wx.GetApp(),
+ 'frame' : self,
+ }
+ self.shell = py.shell.ShellFrame(None, locals=namespace)
+ self.shell.SetSize((640,480))
+ self.shell.Show()
+
+ # Hook the close event of the main frame window so that we
+ # close the shell at the same time if it still exists
+ def CloseShell(evt):
+ if self.shell:
+ self.shell.Close()
+ evt.Skip()
+ self.Bind(wx.EVT_CLOSE, CloseShell)
+
+
#---------------------------------------------
def OnCloseWindow(self, event):
self.dying = True
#---------------------------------------------
def OnCloseWindow(self, event):
self.dying = True
and forth between the default and your edited version, and any errors
ocurring upon the reload are reported on the Demo tab.
and forth between the default and your edited version, and any errors
ocurring upon the reload are reported on the Demo tab.
+Added a menu item in the demo that will open a PyShell window that has
+the app and demo frame preloaded in the namespace. This is another
+good way to explore and play with the objects in the currently running
+sample. For example, load the Button sample and then do the following
+in the PyShell::
+
+ >>> b = frame.demoPage.GetChildren()[0]
+ >>> for x in range(0, 500, 10):
+ ... b.Move((x, 50))
+ ... app.Yield(True)
+ ... wx.MilliSleep(10)
+