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
|
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 |
|
# check options:
|
||||||
wx.ICON_INFORMATION)
|
import sys, getopt
|
||||||
dlg.ShowModal()
|
optlist, args = getopt.getopt(sys.argv[1:],'l',["local","all","text","map","stext","hit","hitf","animate","speed","temp","props"])
|
||||||
dlg.Destroy()
|
|
||||||
|
|
||||||
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:
|
class TestPanel(wx.Panel):
|
||||||
if opt[0] == "--all":
|
def __init__(self, parent, log):
|
||||||
StartUpDemo = "all"
|
self.log = log
|
||||||
elif opt[0] == "--text":
|
wx.Panel.__init__(self, parent, -1)
|
||||||
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
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
b = wx.Button(self, -1, "Show the FloatBar sample", (50,50))
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
|
||||||
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)
|
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
|
@@ -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:
|
buttonDefs = {
|
||||||
def runTest(frame, nb, log):
|
wx.NewId() : ('CubeCanvas', 'Cube'),
|
||||||
dlg = wx.MessageDialog(frame,
|
wx.NewId() : ('ConeCanvas', 'Cone'),
|
||||||
'The OpenGL package was not found. You can get it at\n'
|
}
|
||||||
'http://PyOpenGL.sourceforge.net/',
|
|
||||||
'Sorry', wx.OK | wx.ICON_INFORMATION)
|
class ButtonPanel(wx.Panel):
|
||||||
dlg.ShowModal()
|
def __init__(self, parent, log):
|
||||||
dlg.Destroy()
|
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:
|
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):
|
|
||||||
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,179 +73,171 @@ else:
|
|||||||
frame.Show(True)
|
frame.Show(True)
|
||||||
|
|
||||||
|
|
||||||
|
class MyCanvasBase(glcanvas.GLCanvas):
|
||||||
def runTest(frame, nb, log):
|
def __init__(self, parent):
|
||||||
win = ButtonPanel(nb, log)
|
glcanvas.GLCanvas.__init__(self, parent, -1)
|
||||||
return win
|
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 OnSize(self, event):
|
||||||
def __init__(self, parent):
|
size = self.GetClientSize()
|
||||||
glcanvas.GLCanvas.__init__(self, parent, -1)
|
if self.GetContext():
|
||||||
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)
|
|
||||||
self.SetCurrent()
|
self.SetCurrent()
|
||||||
if not self.init:
|
glViewport(0, 0, size.width, size.height)
|
||||||
self.InitGL()
|
event.Skip()
|
||||||
self.init = True
|
|
||||||
self.OnDraw()
|
|
||||||
|
|
||||||
|
|
||||||
def OnMouseDown(self, evt):
|
def OnPaint(self, event):
|
||||||
self.CaptureMouse()
|
dc = wx.PaintDC(self)
|
||||||
|
self.SetCurrent()
|
||||||
|
if not self.init:
|
||||||
|
self.InitGL()
|
||||||
|
self.init = True
|
||||||
|
self.OnDraw()
|
||||||
|
|
||||||
|
|
||||||
def OnMouseUp(self, evt):
|
def OnMouseDown(self, evt):
|
||||||
self.ReleaseMouse()
|
self.CaptureMouse()
|
||||||
|
|
||||||
|
|
||||||
def OnMouseMotion(self, evt):
|
def OnMouseUp(self, evt):
|
||||||
if evt.Dragging() and evt.LeftIsDown():
|
self.ReleaseMouse()
|
||||||
self.x, self.y = self.lastx, self.lasty
|
|
||||||
self.x, self.y = evt.GetPosition()
|
|
||||||
self.Refresh(False)
|
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):
|
class CubeCanvas(MyCanvasBase):
|
||||||
def InitGL(self):
|
def InitGL(self):
|
||||||
# set viewing projection
|
# set viewing projection
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glFrustum(-0.5, 0.5, -0.5, 0.5, 1.0, 3.0);
|
glFrustum(-0.5, 0.5, -0.5, 0.5, 1.0, 3.0);
|
||||||
|
|
||||||
# position viewer
|
# position viewer
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glTranslatef(0.0, 0.0, -2.0);
|
glTranslatef(0.0, 0.0, -2.0);
|
||||||
|
|
||||||
# position object
|
# position object
|
||||||
glRotatef(self.y, 1.0, 0.0, 0.0);
|
glRotatef(self.y, 1.0, 0.0, 0.0);
|
||||||
glRotatef(self.x, 0.0, 1.0, 0.0);
|
glRotatef(self.x, 0.0, 1.0, 0.0);
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
glEnable(GL_LIGHT0);
|
glEnable(GL_LIGHT0);
|
||||||
|
|
||||||
|
|
||||||
def OnDraw(self):
|
def OnDraw(self):
|
||||||
# clear color and depth buffers
|
# clear color and depth buffers
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
# draw six faces of a cube
|
# draw six faces of a cube
|
||||||
glBegin(GL_QUADS)
|
glBegin(GL_QUADS)
|
||||||
glNormal3f( 0.0, 0.0, 1.0)
|
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)
|
||||||
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)
|
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)
|
||||||
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)
|
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)
|
||||||
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)
|
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)
|
||||||
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)
|
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)
|
||||||
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)
|
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)
|
||||||
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()
|
glEnd()
|
||||||
|
|
||||||
glRotatef((self.lasty - self.y)/100., 1.0, 0.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);
|
glRotatef((self.lastx - self.x)/100., 0.0, 1.0, 0.0);
|
||||||
|
|
||||||
self.SwapBuffers()
|
self.SwapBuffers()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ConeCanvas(MyCanvasBase):
|
class ConeCanvas(MyCanvasBase):
|
||||||
def InitGL( self ):
|
def InitGL( self ):
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
# camera frustrum setup
|
# camera frustrum setup
|
||||||
glFrustum(-0.5, 0.5, -0.5, 0.5, 1.0, 3.0);
|
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_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_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_SPECULAR, [1.0, 0.0, 1.0, 1.0])
|
||||||
glMaterial(GL_FRONT, GL_SHININESS, 50.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_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_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_SPECULAR, [1.0, 1.0, 1.0, 1.0])
|
||||||
glLight(GL_LIGHT0, GL_POSITION, [1.0, 1.0, 1.0, 0.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])
|
glLightModel(GL_LIGHT_MODEL_AMBIENT, [0.2, 0.2, 0.2, 1.0])
|
||||||
glEnable(GL_LIGHTING)
|
glEnable(GL_LIGHTING)
|
||||||
glEnable(GL_LIGHT0)
|
glEnable(GL_LIGHT0)
|
||||||
glDepthFunc(GL_LESS)
|
glDepthFunc(GL_LESS)
|
||||||
glEnable(GL_DEPTH_TEST)
|
glEnable(GL_DEPTH_TEST)
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
||||||
# position viewer
|
# position viewer
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
|
||||||
|
|
||||||
def OnDraw(self):
|
def OnDraw(self):
|
||||||
# clear color and depth buffers
|
# clear color and depth buffers
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
# use a fresh transformation matrix
|
# use a fresh transformation matrix
|
||||||
glPushMatrix()
|
glPushMatrix()
|
||||||
# position object
|
# position object
|
||||||
glTranslate(0.0, 0.0, -2.0);
|
glTranslate(0.0, 0.0, -2.0);
|
||||||
glRotate(30.0, 1.0, 0.0, 0.0);
|
glRotate(30.0, 1.0, 0.0, 0.0);
|
||||||
glRotate(30.0, 0.0, 1.0, 0.0);
|
glRotate(30.0, 0.0, 1.0, 0.0);
|
||||||
|
|
||||||
glTranslate(0, -1, 0)
|
glTranslate(0, -1, 0)
|
||||||
glRotate(250, 1, 0, 0)
|
glRotate(250, 1, 0, 0)
|
||||||
glutSolidCone(0.5, 1, 30, 5)
|
glutSolidCone(0.5, 1, 30, 5)
|
||||||
glPopMatrix()
|
glPopMatrix()
|
||||||
glRotatef((self.lasty - self.y)/100., 0.0, 0.0, 1.0);
|
glRotatef((self.lasty - self.y)/100., 0.0, 0.0, 1.0);
|
||||||
glRotatef(0.0, (self.lastx - self.x)/100., 1.0, 0.0);
|
glRotatef(0.0, (self.lastx - self.x)/100., 1.0, 0.0);
|
||||||
# push into visible buffer
|
# push into visible buffer
|
||||||
self.SwapBuffers()
|
self.SwapBuffers()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -256,6 +245,13 @@ else:
|
|||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
def runTest(frame, nb, log):
|
||||||
|
win = ButtonPanel(nb, log)
|
||||||
|
return win
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
overview = """\
|
overview = """\
|
||||||
|
@@ -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)
|
||||||
|
@@ -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)
|
||||||
|
Reference in New Issue
Block a user