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:
@@ -21,69 +21,65 @@ NOTE: The Numeric module is substantially faster than numarray for this
|
||||
purpose, if you have lot's of objects
|
||||
"""
|
||||
|
||||
import wx
|
||||
def runTest(frame, nb, log):
|
||||
dlg = wx.MessageDialog(frame, errorText, 'Sorry', wx.OK |
|
||||
wx.ICON_INFORMATION)
|
||||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
StartUpDemo = "all"
|
||||
if __name__ == "__main__": # parse options if run stand-alone
|
||||
# check options:
|
||||
import sys, getopt
|
||||
optlist, args = getopt.getopt(sys.argv[1:],'l',["local","all","text","map","stext","hit","hitf","animate","speed","temp","props"])
|
||||
|
||||
overview = ""
|
||||
for opt in optlist:
|
||||
if opt[0] == "--all":
|
||||
StartUpDemo = "all"
|
||||
elif opt[0] == "--text":
|
||||
StartUpDemo = "text"
|
||||
elif opt[0] == "--map":
|
||||
StartUpDemo = "map"
|
||||
elif opt[0] == "--stext":
|
||||
StartUpDemo = "stext"
|
||||
elif opt[0] == "--hit":
|
||||
StartUpDemo = "hit"
|
||||
elif opt[0] == "--hitf":
|
||||
StartUpDemo = "hitf"
|
||||
elif opt[0] == "--animate":
|
||||
StartUpDemo = "animate"
|
||||
elif opt[0] == "--speed":
|
||||
StartUpDemo = "speed"
|
||||
elif opt[0] == "--temp":
|
||||
StartUpDemo = "temp"
|
||||
elif opt[0] == "--props":
|
||||
StartUpDemo = "props"
|
||||
import wx
|
||||
import time, random
|
||||
|
||||
else:
|
||||
StartUpDemo = "all"
|
||||
if __name__ == "__main__": # parse options if run stand-alone
|
||||
# check options:
|
||||
import sys, getopt
|
||||
optlist, args = getopt.getopt(sys.argv[1:],'l',["local","all","text","map","stext","hit","hitf","animate","speed","temp","props"])
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
for opt in optlist:
|
||||
if opt[0] == "--all":
|
||||
StartUpDemo = "all"
|
||||
elif opt[0] == "--text":
|
||||
StartUpDemo = "text"
|
||||
elif opt[0] == "--map":
|
||||
StartUpDemo = "map"
|
||||
elif opt[0] == "--stext":
|
||||
StartUpDemo = "stext"
|
||||
elif opt[0] == "--hit":
|
||||
StartUpDemo = "hit"
|
||||
elif opt[0] == "--hitf":
|
||||
StartUpDemo = "hitf"
|
||||
elif opt[0] == "--animate":
|
||||
StartUpDemo = "animate"
|
||||
elif opt[0] == "--speed":
|
||||
StartUpDemo = "speed"
|
||||
elif opt[0] == "--temp":
|
||||
StartUpDemo = "temp"
|
||||
elif opt[0] == "--props":
|
||||
StartUpDemo = "props"
|
||||
import wx
|
||||
import time, random
|
||||
class TestPanel(wx.Panel):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wx.Panel.__init__(self, parent, -1)
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wx.Panel):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wx.Panel.__init__(self, parent, -1)
|
||||
|
||||
b = wx.Button(self, -1, "Show the FloatBar sample", (50,50))
|
||||
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
|
||||
b = wx.Button(self, -1, "Show the FloatBar sample", (50,50))
|
||||
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
|
||||
|
||||
|
||||
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.Show(True)
|
||||
win.DrawTest()
|
||||
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
if haveNumeric:
|
||||
|
||||
try:
|
||||
from floatcanvas import NavCanvas, FloatCanvas
|
||||
@@ -1344,7 +1340,15 @@ else:
|
||||
else:
|
||||
return Shorelines
|
||||
|
||||
## for the wxPython demo:
|
||||
#---------------------------------------------------------------------------
|
||||
## for the wxPython demo:
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
|
||||
if haveNumeric:
|
||||
try:
|
||||
import floatcanvas
|
||||
except ImportError: # if it's not there locally, try the wxPython lib.
|
||||
@@ -1352,6 +1356,12 @@ else:
|
||||
|
||||
overview = floatcanvas.__doc__
|
||||
|
||||
else:
|
||||
overview = ""
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if not haveNumeric:
|
||||
print errorText
|
||||
|
@@ -18,57 +18,54 @@ 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:
|
||||
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()
|
||||
buttonDefs = {
|
||||
wx.NewId() : ('CubeCanvas', 'Cube'),
|
||||
wx.NewId() : ('ConeCanvas', 'Cone'),
|
||||
}
|
||||
|
||||
class ButtonPanel(wx.Panel):
|
||||
def __init__(self, parent, log):
|
||||
wx.Panel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
|
||||
box = wx.BoxSizer(wx.VERTICAL)
|
||||
box.Add((20, 30))
|
||||
keys = buttonDefs.keys()
|
||||
keys.sort()
|
||||
for k in keys:
|
||||
text = buttonDefs[k][1]
|
||||
btn = wx.Button(self, k, text)
|
||||
box.Add(btn, 0, wx.ALIGN_CENTER|wx.ALL, 15)
|
||||
self.Bind(wx.EVT_BUTTON, self.OnButton, btn)
|
||||
|
||||
#** Enable this to show putting a GLCanvas on the wx.Panel
|
||||
if 0:
|
||||
c = CubeCanvas(self)
|
||||
c.SetSize((200, 200))
|
||||
box.Add(c, 0, wx.ALIGN_CENTER|wx.ALL, 15)
|
||||
|
||||
self.SetAutoLayout(True)
|
||||
self.SetSizer(box)
|
||||
|
||||
|
||||
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:
|
||||
buttonDefs = {
|
||||
wx.NewId() : ('CubeCanvas', 'Cube'),
|
||||
wx.NewId() : ('ConeCanvas', 'Cone'),
|
||||
}
|
||||
|
||||
class ButtonPanel(wx.Panel):
|
||||
def __init__(self, parent, log):
|
||||
wx.Panel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
|
||||
box = wx.BoxSizer(wx.VERTICAL)
|
||||
box.Add((20, 30))
|
||||
keys = buttonDefs.keys()
|
||||
keys.sort()
|
||||
for k in keys:
|
||||
text = buttonDefs[k][1]
|
||||
btn = wx.Button(self, k, text)
|
||||
box.Add(btn, 0, wx.ALIGN_CENTER|wx.ALL, 15)
|
||||
self.Bind(wx.EVT_BUTTON, self.OnButton, btn)
|
||||
|
||||
#** Enable this to show putting a GLCanvas on the wx.Panel
|
||||
if 0:
|
||||
c = CubeCanvas(self)
|
||||
c.SetSize((200, 200))
|
||||
box.Add(c, 0, wx.ALIGN_CENTER|wx.ALL, 15)
|
||||
|
||||
self.SetAutoLayout(True)
|
||||
self.SetSizer(box)
|
||||
|
||||
|
||||
def OnButton(self, evt):
|
||||
else:
|
||||
canvasClassName = buttonDefs[evt.GetId()][0]
|
||||
canvasClass = eval(canvasClassName)
|
||||
frame = wx.Frame(None, -1, canvasClassName, size=(400,400))
|
||||
@@ -76,179 +73,171 @@ else:
|
||||
frame.Show(True)
|
||||
|
||||
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = ButtonPanel(nb, log)
|
||||
return win
|
||||
class MyCanvasBase(glcanvas.GLCanvas):
|
||||
def __init__(self, parent):
|
||||
glcanvas.GLCanvas.__init__(self, parent, -1)
|
||||
self.init = False
|
||||
# initial mouse position
|
||||
self.lastx = self.x = 30
|
||||
self.lasty = self.y = 30
|
||||
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
|
||||
self.Bind(wx.EVT_SIZE, self.OnSize)
|
||||
self.Bind(wx.EVT_PAINT, self.OnPaint)
|
||||
self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown)
|
||||
self.Bind(wx.EVT_LEFT_UP, self.OnMouseUp)
|
||||
self.Bind(wx.EVT_MOTION, self.OnMouseMotion)
|
||||
|
||||
|
||||
def OnEraseBackground(self, event):
|
||||
pass # Do nothing, to avoid flashing on MSW.
|
||||
|
||||
|
||||
class MyCanvasBase(glcanvas.GLCanvas):
|
||||
def __init__(self, parent):
|
||||
glcanvas.GLCanvas.__init__(self, parent, -1)
|
||||
self.init = False
|
||||
# initial mouse position
|
||||
self.lastx = self.x = 30
|
||||
self.lasty = self.y = 30
|
||||
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
|
||||
self.Bind(wx.EVT_SIZE, self.OnSize)
|
||||
self.Bind(wx.EVT_PAINT, self.OnPaint)
|
||||
self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown)
|
||||
self.Bind(wx.EVT_LEFT_UP, self.OnMouseUp)
|
||||
self.Bind(wx.EVT_MOTION, self.OnMouseMotion)
|
||||
|
||||
|
||||
def OnEraseBackground(self, event):
|
||||
pass # Do nothing, to avoid flashing on MSW.
|
||||
|
||||
|
||||
def OnSize(self, event):
|
||||
size = self.GetClientSize()
|
||||
if self.GetContext():
|
||||
self.SetCurrent()
|
||||
glViewport(0, 0, size.width, size.height)
|
||||
event.Skip()
|
||||
|
||||
|
||||
def OnPaint(self, event):
|
||||
dc = wx.PaintDC(self)
|
||||
def OnSize(self, event):
|
||||
size = self.GetClientSize()
|
||||
if self.GetContext():
|
||||
self.SetCurrent()
|
||||
if not self.init:
|
||||
self.InitGL()
|
||||
self.init = True
|
||||
self.OnDraw()
|
||||
glViewport(0, 0, size.width, size.height)
|
||||
event.Skip()
|
||||
|
||||
|
||||
def OnMouseDown(self, evt):
|
||||
self.CaptureMouse()
|
||||
def OnPaint(self, event):
|
||||
dc = wx.PaintDC(self)
|
||||
self.SetCurrent()
|
||||
if not self.init:
|
||||
self.InitGL()
|
||||
self.init = True
|
||||
self.OnDraw()
|
||||
|
||||
|
||||
def OnMouseUp(self, evt):
|
||||
self.ReleaseMouse()
|
||||
def OnMouseDown(self, evt):
|
||||
self.CaptureMouse()
|
||||
|
||||
|
||||
def OnMouseMotion(self, evt):
|
||||
if evt.Dragging() and evt.LeftIsDown():
|
||||
self.x, self.y = self.lastx, self.lasty
|
||||
self.x, self.y = evt.GetPosition()
|
||||
self.Refresh(False)
|
||||
def OnMouseUp(self, evt):
|
||||
self.ReleaseMouse()
|
||||
|
||||
|
||||
def OnMouseMotion(self, evt):
|
||||
if evt.Dragging() and evt.LeftIsDown():
|
||||
self.x, self.y = self.lastx, self.lasty
|
||||
self.x, self.y = evt.GetPosition()
|
||||
self.Refresh(False)
|
||||
|
||||
|
||||
|
||||
|
||||
class CubeCanvas(MyCanvasBase):
|
||||
def InitGL(self):
|
||||
# set viewing projection
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glFrustum(-0.5, 0.5, -0.5, 0.5, 1.0, 3.0);
|
||||
class CubeCanvas(MyCanvasBase):
|
||||
def InitGL(self):
|
||||
# set viewing projection
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glFrustum(-0.5, 0.5, -0.5, 0.5, 1.0, 3.0);
|
||||
|
||||
# position viewer
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glTranslatef(0.0, 0.0, -2.0);
|
||||
# position viewer
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glTranslatef(0.0, 0.0, -2.0);
|
||||
|
||||
# position object
|
||||
glRotatef(self.y, 1.0, 0.0, 0.0);
|
||||
glRotatef(self.x, 0.0, 1.0, 0.0);
|
||||
# position object
|
||||
glRotatef(self.y, 1.0, 0.0, 0.0);
|
||||
glRotatef(self.x, 0.0, 1.0, 0.0);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
|
||||
|
||||
def OnDraw(self):
|
||||
# clear color and depth buffers
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
def OnDraw(self):
|
||||
# clear color and depth buffers
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
# draw six faces of a cube
|
||||
glBegin(GL_QUADS)
|
||||
glNormal3f( 0.0, 0.0, 1.0)
|
||||
glVertex3f( 0.5, 0.5, 0.5)
|
||||
glVertex3f(-0.5, 0.5, 0.5)
|
||||
glVertex3f(-0.5,-0.5, 0.5)
|
||||
glVertex3f( 0.5,-0.5, 0.5)
|
||||
# draw six faces of a cube
|
||||
glBegin(GL_QUADS)
|
||||
glNormal3f( 0.0, 0.0, 1.0)
|
||||
glVertex3f( 0.5, 0.5, 0.5)
|
||||
glVertex3f(-0.5, 0.5, 0.5)
|
||||
glVertex3f(-0.5,-0.5, 0.5)
|
||||
glVertex3f( 0.5,-0.5, 0.5)
|
||||
|
||||
glNormal3f( 0.0, 0.0,-1.0)
|
||||
glVertex3f(-0.5,-0.5,-0.5)
|
||||
glVertex3f(-0.5, 0.5,-0.5)
|
||||
glVertex3f( 0.5, 0.5,-0.5)
|
||||
glVertex3f( 0.5,-0.5,-0.5)
|
||||
glNormal3f( 0.0, 0.0,-1.0)
|
||||
glVertex3f(-0.5,-0.5,-0.5)
|
||||
glVertex3f(-0.5, 0.5,-0.5)
|
||||
glVertex3f( 0.5, 0.5,-0.5)
|
||||
glVertex3f( 0.5,-0.5,-0.5)
|
||||
|
||||
glNormal3f( 0.0, 1.0, 0.0)
|
||||
glVertex3f( 0.5, 0.5, 0.5)
|
||||
glVertex3f( 0.5, 0.5,-0.5)
|
||||
glVertex3f(-0.5, 0.5,-0.5)
|
||||
glVertex3f(-0.5, 0.5, 0.5)
|
||||
glNormal3f( 0.0, 1.0, 0.0)
|
||||
glVertex3f( 0.5, 0.5, 0.5)
|
||||
glVertex3f( 0.5, 0.5,-0.5)
|
||||
glVertex3f(-0.5, 0.5,-0.5)
|
||||
glVertex3f(-0.5, 0.5, 0.5)
|
||||
|
||||
glNormal3f( 0.0,-1.0, 0.0)
|
||||
glVertex3f(-0.5,-0.5,-0.5)
|
||||
glVertex3f( 0.5,-0.5,-0.5)
|
||||
glVertex3f( 0.5,-0.5, 0.5)
|
||||
glVertex3f(-0.5,-0.5, 0.5)
|
||||
glNormal3f( 0.0,-1.0, 0.0)
|
||||
glVertex3f(-0.5,-0.5,-0.5)
|
||||
glVertex3f( 0.5,-0.5,-0.5)
|
||||
glVertex3f( 0.5,-0.5, 0.5)
|
||||
glVertex3f(-0.5,-0.5, 0.5)
|
||||
|
||||
glNormal3f( 1.0, 0.0, 0.0)
|
||||
glVertex3f( 0.5, 0.5, 0.5)
|
||||
glVertex3f( 0.5,-0.5, 0.5)
|
||||
glVertex3f( 0.5,-0.5,-0.5)
|
||||
glVertex3f( 0.5, 0.5,-0.5)
|
||||
glNormal3f( 1.0, 0.0, 0.0)
|
||||
glVertex3f( 0.5, 0.5, 0.5)
|
||||
glVertex3f( 0.5,-0.5, 0.5)
|
||||
glVertex3f( 0.5,-0.5,-0.5)
|
||||
glVertex3f( 0.5, 0.5,-0.5)
|
||||
|
||||
glNormal3f(-1.0, 0.0, 0.0)
|
||||
glVertex3f(-0.5,-0.5,-0.5)
|
||||
glVertex3f(-0.5,-0.5, 0.5)
|
||||
glVertex3f(-0.5, 0.5, 0.5)
|
||||
glVertex3f(-0.5, 0.5,-0.5)
|
||||
glEnd()
|
||||
glNormal3f(-1.0, 0.0, 0.0)
|
||||
glVertex3f(-0.5,-0.5,-0.5)
|
||||
glVertex3f(-0.5,-0.5, 0.5)
|
||||
glVertex3f(-0.5, 0.5, 0.5)
|
||||
glVertex3f(-0.5, 0.5,-0.5)
|
||||
glEnd()
|
||||
|
||||
glRotatef((self.lasty - self.y)/100., 1.0, 0.0, 0.0);
|
||||
glRotatef((self.lastx - self.x)/100., 0.0, 1.0, 0.0);
|
||||
glRotatef((self.lasty - self.y)/100., 1.0, 0.0, 0.0);
|
||||
glRotatef((self.lastx - self.x)/100., 0.0, 1.0, 0.0);
|
||||
|
||||
self.SwapBuffers()
|
||||
self.SwapBuffers()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class ConeCanvas(MyCanvasBase):
|
||||
def InitGL( self ):
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
# camera frustrum setup
|
||||
glFrustum(-0.5, 0.5, -0.5, 0.5, 1.0, 3.0);
|
||||
glMaterial(GL_FRONT, GL_AMBIENT, [0.2, 0.2, 0.2, 1.0])
|
||||
glMaterial(GL_FRONT, GL_DIFFUSE, [0.8, 0.8, 0.8, 1.0])
|
||||
glMaterial(GL_FRONT, GL_SPECULAR, [1.0, 0.0, 1.0, 1.0])
|
||||
glMaterial(GL_FRONT, GL_SHININESS, 50.0)
|
||||
glLight(GL_LIGHT0, GL_AMBIENT, [0.0, 1.0, 0.0, 1.0])
|
||||
glLight(GL_LIGHT0, GL_DIFFUSE, [1.0, 1.0, 1.0, 1.0])
|
||||
glLight(GL_LIGHT0, GL_SPECULAR, [1.0, 1.0, 1.0, 1.0])
|
||||
glLight(GL_LIGHT0, GL_POSITION, [1.0, 1.0, 1.0, 0.0]);
|
||||
glLightModel(GL_LIGHT_MODEL_AMBIENT, [0.2, 0.2, 0.2, 1.0])
|
||||
glEnable(GL_LIGHTING)
|
||||
glEnable(GL_LIGHT0)
|
||||
glDepthFunc(GL_LESS)
|
||||
glEnable(GL_DEPTH_TEST)
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
||||
# position viewer
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
class ConeCanvas(MyCanvasBase):
|
||||
def InitGL( self ):
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
# camera frustrum setup
|
||||
glFrustum(-0.5, 0.5, -0.5, 0.5, 1.0, 3.0);
|
||||
glMaterial(GL_FRONT, GL_AMBIENT, [0.2, 0.2, 0.2, 1.0])
|
||||
glMaterial(GL_FRONT, GL_DIFFUSE, [0.8, 0.8, 0.8, 1.0])
|
||||
glMaterial(GL_FRONT, GL_SPECULAR, [1.0, 0.0, 1.0, 1.0])
|
||||
glMaterial(GL_FRONT, GL_SHININESS, 50.0)
|
||||
glLight(GL_LIGHT0, GL_AMBIENT, [0.0, 1.0, 0.0, 1.0])
|
||||
glLight(GL_LIGHT0, GL_DIFFUSE, [1.0, 1.0, 1.0, 1.0])
|
||||
glLight(GL_LIGHT0, GL_SPECULAR, [1.0, 1.0, 1.0, 1.0])
|
||||
glLight(GL_LIGHT0, GL_POSITION, [1.0, 1.0, 1.0, 0.0]);
|
||||
glLightModel(GL_LIGHT_MODEL_AMBIENT, [0.2, 0.2, 0.2, 1.0])
|
||||
glEnable(GL_LIGHTING)
|
||||
glEnable(GL_LIGHT0)
|
||||
glDepthFunc(GL_LESS)
|
||||
glEnable(GL_DEPTH_TEST)
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
||||
# position viewer
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
|
||||
def OnDraw(self):
|
||||
# clear color and depth buffers
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
# use a fresh transformation matrix
|
||||
glPushMatrix()
|
||||
# position object
|
||||
glTranslate(0.0, 0.0, -2.0);
|
||||
glRotate(30.0, 1.0, 0.0, 0.0);
|
||||
glRotate(30.0, 0.0, 1.0, 0.0);
|
||||
def OnDraw(self):
|
||||
# clear color and depth buffers
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
# use a fresh transformation matrix
|
||||
glPushMatrix()
|
||||
# position object
|
||||
glTranslate(0.0, 0.0, -2.0);
|
||||
glRotate(30.0, 1.0, 0.0, 0.0);
|
||||
glRotate(30.0, 0.0, 1.0, 0.0);
|
||||
|
||||
glTranslate(0, -1, 0)
|
||||
glRotate(250, 1, 0, 0)
|
||||
glutSolidCone(0.5, 1, 30, 5)
|
||||
glPopMatrix()
|
||||
glRotatef((self.lasty - self.y)/100., 0.0, 0.0, 1.0);
|
||||
glRotatef(0.0, (self.lastx - self.x)/100., 1.0, 0.0);
|
||||
# push into visible buffer
|
||||
self.SwapBuffers()
|
||||
glTranslate(0, -1, 0)
|
||||
glRotate(250, 1, 0, 0)
|
||||
glutSolidCone(0.5, 1, 30, 5)
|
||||
glPopMatrix()
|
||||
glRotatef((self.lasty - self.y)/100., 0.0, 0.0, 1.0);
|
||||
glRotatef(0.0, (self.lastx - self.x)/100., 1.0, 0.0);
|
||||
# push into visible buffer
|
||||
self.SwapBuffers()
|
||||
|
||||
|
||||
|
||||
@@ -256,6 +245,13 @@ else:
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = ButtonPanel(nb, log)
|
||||
return win
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
|
@@ -273,7 +273,7 @@ try:
|
||||
|
||||
class DemoCodeEditor(PythonSTC):
|
||||
def __init__(self, parent):
|
||||
PythonSTC.__init__(self, parent, -1, wx.BORDER_NONE)
|
||||
PythonSTC.__init__(self, parent, -1, style=wx.BORDER_NONE)
|
||||
self.SetUpEditor()
|
||||
|
||||
# Some methods to make it compatible with how the wxTextCtrl is used
|
||||
@@ -443,8 +443,8 @@ try:
|
||||
except ImportError:
|
||||
class DemoCodeEditor(wx.TextCtrl):
|
||||
def __init__(self, parent):
|
||||
wx.TextCtrl.__init__(self, parent, -1, style = wx.TE_MULTILINE |
|
||||
wx.HSCROLL | wx.TE_RICH2 | wx.TE_NOHIDESEL)
|
||||
wx.TextCtrl.__init__(self, parent, -1, style =
|
||||
wx.TE_MULTILINE | wx.HSCROLL | wx.TE_RICH2 | wx.TE_NOHIDESEL)
|
||||
|
||||
def RegisterModifiedEvent(self, eventHandler):
|
||||
self.Bind(wx.EVT_TEXT, eventHandler)
|
||||
@@ -482,7 +482,8 @@ modDefault = modOriginal
|
||||
class DemoCodePanel(wx.Panel):
|
||||
"""Panel for the 'Demo Code' tab"""
|
||||
def __init__(self, parent, mainFrame):
|
||||
wx.Panel.__init__(self, parent)
|
||||
wx.Panel.__init__(self, parent, size=(1,1))
|
||||
self.Hide()
|
||||
self.mainFrame = mainFrame
|
||||
self.editor = DemoCodeEditor(self)
|
||||
self.editor.RegisterModifiedEvent(self.OnCodeModified)
|
||||
|
@@ -42,9 +42,10 @@ class PythonSTC(stc.StyledTextCtrl):
|
||||
|
||||
fold_symbols = 2
|
||||
|
||||
def __init__(self, parent, ID, style=0):
|
||||
stc.StyledTextCtrl.__init__(self, parent, ID,
|
||||
style = style|wx.NO_FULL_REPAINT_ON_RESIZE)
|
||||
def __init__(self, parent, ID,
|
||||
pos=wx.DefaultPosition, size=wx.DefaultSize,
|
||||
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('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
|
||||
|
Reference in New Issue
Block a user