Ensure that runTest is not modal, even when a required module is not

installed.

Create the code page small and hide it to reduce flicker, it will
later be shown and sized correctly when put into the notebook.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28918 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2004-08-25 23:56:43 +00:00
parent 3801d366cb
commit 2e839e966d
4 changed files with 339 additions and 331 deletions

View File

@@ -21,18 +21,8 @@ NOTE: The Numeric module is substantially faster than numarray for this
purpose, if you have lot's of objects purpose, if you have lot's of objects
""" """
import wx StartUpDemo = "all"
def runTest(frame, nb, log): if __name__ == "__main__": # parse options if run stand-alone
dlg = wx.MessageDialog(frame, errorText, 'Sorry', wx.OK |
wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
overview = ""
else:
StartUpDemo = "all"
if __name__ == "__main__": # parse options if run stand-alone
# check options: # check options:
import sys, getopt import sys, getopt
optlist, args = getopt.getopt(sys.argv[1:],'l',["local","all","text","map","stext","hit","hitf","animate","speed","temp","props"]) optlist, args = getopt.getopt(sys.argv[1:],'l',["local","all","text","map","stext","hit","hitf","animate","speed","temp","props"])
@@ -58,12 +48,12 @@ else:
StartUpDemo = "temp" StartUpDemo = "temp"
elif opt[0] == "--props": elif opt[0] == "--props":
StartUpDemo = "props" StartUpDemo = "props"
import wx import wx
import time, random import time, random
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
class TestPanel(wx.Panel): class TestPanel(wx.Panel):
def __init__(self, parent, log): def __init__(self, parent, log):
self.log = log self.log = log
wx.Panel.__init__(self, parent, -1) wx.Panel.__init__(self, parent, -1)
@@ -73,17 +63,23 @@ else:
def OnButton(self, evt): def OnButton(self, evt):
if not haveNumeric:
dlg = wx.MessageDialog(self, errorText, 'Sorry', wx.OK |
wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
else:
win = DrawFrame(None, -1, "FloatCanvas Drawing Window",wx.DefaultPosition,(500,500)) win = DrawFrame(None, -1, "FloatCanvas Drawing Window",wx.DefaultPosition,(500,500))
win.Show(True) win.Show(True)
win.DrawTest() win.DrawTest()
def runTest(frame, nb, log):
win = TestPanel(nb, log) #---------------------------------------------------------------------------
return win
if haveNumeric:
try: try:
from floatcanvas import NavCanvas, FloatCanvas from floatcanvas import NavCanvas, FloatCanvas
@@ -1344,7 +1340,15 @@ else:
else: else:
return Shorelines return Shorelines
## for the wxPython demo: #---------------------------------------------------------------------------
## for the wxPython demo:
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
if haveNumeric:
try: try:
import floatcanvas import floatcanvas
except ImportError: # if it's not there locally, try the wxPython lib. except ImportError: # if it's not there locally, try the wxPython lib.
@@ -1352,6 +1356,12 @@ else:
overview = floatcanvas.__doc__ overview = floatcanvas.__doc__
else:
overview = ""
if __name__ == "__main__": if __name__ == "__main__":
if not haveNumeric: if not haveNumeric:
print errorText print errorText

View File

@@ -18,32 +18,13 @@ except ImportError:
#---------------------------------------------------------------------- #----------------------------------------------------------------------
if not haveGLCanvas:
def runTest(frame, nb, log):
dlg = wx.MessageDialog(frame, 'The GLCanvas class has not been included with this build of wxPython!',
'Sorry', wx.OK | wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
elif not haveOpenGL: buttonDefs = {
def runTest(frame, nb, log):
dlg = wx.MessageDialog(frame,
'The OpenGL package was not found. You can get it at\n'
'http://PyOpenGL.sourceforge.net/',
'Sorry', wx.OK | wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
else:
buttonDefs = {
wx.NewId() : ('CubeCanvas', 'Cube'), wx.NewId() : ('CubeCanvas', 'Cube'),
wx.NewId() : ('ConeCanvas', 'Cone'), wx.NewId() : ('ConeCanvas', 'Cone'),
} }
class ButtonPanel(wx.Panel): class ButtonPanel(wx.Panel):
def __init__(self, parent, log): def __init__(self, parent, log):
wx.Panel.__init__(self, parent, -1) wx.Panel.__init__(self, parent, -1)
self.log = log self.log = log
@@ -69,6 +50,22 @@ else:
def OnButton(self, evt): def OnButton(self, evt):
if not haveGLCanvas:
dlg = wx.MessageDialog(self,
'The GLCanvas class has not been included with this build of wxPython!',
'Sorry', wx.OK | wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
elif not haveOpenGL:
dlg = wx.MessageDialog(self,
'The OpenGL package was not found. You can get it at\n'
'http://PyOpenGL.sourceforge.net/',
'Sorry', wx.OK | wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
else:
canvasClassName = buttonDefs[evt.GetId()][0] canvasClassName = buttonDefs[evt.GetId()][0]
canvasClass = eval(canvasClassName) canvasClass = eval(canvasClassName)
frame = wx.Frame(None, -1, canvasClassName, size=(400,400)) frame = wx.Frame(None, -1, canvasClassName, size=(400,400))
@@ -76,15 +73,7 @@ else:
frame.Show(True) frame.Show(True)
class MyCanvasBase(glcanvas.GLCanvas):
def runTest(frame, nb, log):
win = ButtonPanel(nb, log)
return win
class MyCanvasBase(glcanvas.GLCanvas):
def __init__(self, parent): def __init__(self, parent):
glcanvas.GLCanvas.__init__(self, parent, -1) glcanvas.GLCanvas.__init__(self, parent, -1)
self.init = False self.init = False
@@ -137,7 +126,7 @@ else:
class CubeCanvas(MyCanvasBase): class CubeCanvas(MyCanvasBase):
def InitGL(self): def InitGL(self):
# set viewing projection # set viewing projection
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
@@ -208,7 +197,7 @@ else:
class ConeCanvas(MyCanvasBase): class ConeCanvas(MyCanvasBase):
def InitGL( self ): def InitGL( self ):
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
# camera frustrum setup # camera frustrum setup
@@ -256,6 +245,13 @@ else:
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def runTest(frame, nb, log):
win = ButtonPanel(nb, log)
return win
overview = """\ overview = """\

View File

@@ -273,7 +273,7 @@ try:
class DemoCodeEditor(PythonSTC): class DemoCodeEditor(PythonSTC):
def __init__(self, parent): def __init__(self, parent):
PythonSTC.__init__(self, parent, -1, wx.BORDER_NONE) PythonSTC.__init__(self, parent, -1, style=wx.BORDER_NONE)
self.SetUpEditor() self.SetUpEditor()
# Some methods to make it compatible with how the wxTextCtrl is used # Some methods to make it compatible with how the wxTextCtrl is used
@@ -443,8 +443,8 @@ try:
except ImportError: except ImportError:
class DemoCodeEditor(wx.TextCtrl): class DemoCodeEditor(wx.TextCtrl):
def __init__(self, parent): def __init__(self, parent):
wx.TextCtrl.__init__(self, parent, -1, style = wx.TE_MULTILINE | wx.TextCtrl.__init__(self, parent, -1, style =
wx.HSCROLL | wx.TE_RICH2 | wx.TE_NOHIDESEL) wx.TE_MULTILINE | wx.HSCROLL | wx.TE_RICH2 | wx.TE_NOHIDESEL)
def RegisterModifiedEvent(self, eventHandler): def RegisterModifiedEvent(self, eventHandler):
self.Bind(wx.EVT_TEXT, eventHandler) self.Bind(wx.EVT_TEXT, eventHandler)
@@ -482,7 +482,8 @@ modDefault = modOriginal
class DemoCodePanel(wx.Panel): class DemoCodePanel(wx.Panel):
"""Panel for the 'Demo Code' tab""" """Panel for the 'Demo Code' tab"""
def __init__(self, parent, mainFrame): def __init__(self, parent, mainFrame):
wx.Panel.__init__(self, parent) wx.Panel.__init__(self, parent, size=(1,1))
self.Hide()
self.mainFrame = mainFrame self.mainFrame = mainFrame
self.editor = DemoCodeEditor(self) self.editor = DemoCodeEditor(self)
self.editor.RegisterModifiedEvent(self.OnCodeModified) self.editor.RegisterModifiedEvent(self.OnCodeModified)

View File

@@ -42,9 +42,10 @@ class PythonSTC(stc.StyledTextCtrl):
fold_symbols = 2 fold_symbols = 2
def __init__(self, parent, ID, style=0): def __init__(self, parent, ID,
stc.StyledTextCtrl.__init__(self, parent, ID, pos=wx.DefaultPosition, size=wx.DefaultSize,
style = style|wx.NO_FULL_REPAINT_ON_RESIZE) style=0):
stc.StyledTextCtrl.__init__(self, parent, ID, pos, size, style)
self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN)
self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)