diff options
author | Bryan Bishop <kanzure@gmail.com> | 2011-06-22 23:13:27 -0500 |
---|---|---|
committer | Bryan Bishop <kanzure@gmail.com> | 2011-06-22 23:13:27 -0500 |
commit | aea8a6850ffd882352fdf2f6cf7381aeeaef1cb5 (patch) | |
tree | b295e6cc7d364a6e53f331dcbb50f35dd93e2652 | |
parent | 3b9790458fb604f080275abfb61f0276be6ef0f6 (diff) | |
download | lolcad-master.tar.gz lolcad-master.zip |
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | nurbs.py | 42 | ||||
-rw-r--r-- | visualizer.py | 364 |
3 files changed, 234 insertions, 174 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d18402d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.pyc +.*.swp @@ -18,6 +18,8 @@ NURBSError = "NURBSError" #see: pyopengl/PyOpenGL-Demo-3.0.1b1/PyOpenGL-Demo/proesch/nurbs/nurbs.py #see: pyopengl/PyOpenGL-Demo-3.0.1b1/PyOpenGL-Demo/proesch/nurbsCurve/nurbsCircle.py #see: pyopengl/PyOpenGL-Demo-3.0.1b1/PyOpenGL-Demo/proesch/nurbsCurve/nurbsCurve.py +#see: csg-boole/boole-1.1/surface/perf_csg.c #perform_CSG +#see: breplibrary/cpp-simple/CSG/main.cpp # ####################################### # *** format for control_points *** @@ -58,7 +60,7 @@ def scale(sxyz): def deg2rad(angle): return math.pi * angle / 180 - +4 def rad2deg(angle): return angle * 180/math.pi @@ -220,13 +222,25 @@ class UnitCircle(NurbsCurve): def __init__(self): r22 = Numeric.sqrt(2)/2 uknots = [0, 0, 0, 0.25, 0.25, 0.5, 0.5, 0.75, 0.75, 1., 1, 1] - control_points = [[0, r22, 1, r22, 0, -r22, -1, -r22, 0], - [-1, -r22, 0, r22, 1, r22, 0, -r22, -1], - [0, 0, 0, 0, 0, 0, 0, 0, 0], - [1, r22, 1, r22, 1, r22, 1, r22, 1]] + control_points = [[0, r22, 1, r22, 0, -r22, -1, -r22, 0], + [-1, -r22, 0, r22, 1, r22, 0, -r22, -1], + [0, 0, 0, 0, 0, 0, 0, 0, 0], + [1, r22, 1, r22, 1, r22, 1, r22, 1]] + control_points = [ + [0, -1, 0, 1], + [r22, -r22, 0, r22], + [1, 0, 0, 1], + [r22, r22, 0, r22], + [0, 1, 0, 1], + [-r22, r22, 0, r22], + [-1, 0, 0, 1], + [-r22, -r22, 0, r22], + [0, -1, 0, 1] + ] NurbsCurve.__init__(self, control_points, uknots) + self.uknots = uknots -class Circle(NurbsCurve): +class Circle(UnitCircle): """NURBS representation of a circle in the xy plane with a given radius (default = 1) and optional center""" def __init__(self, radius=1, center=None): @@ -262,7 +276,8 @@ class Arc(NurbsCurve): y = radius * math.sin(dsweep) xm = x + y * math.tan(dsweep) - #arc segment control points (what is the format?) + + #arc segment control points (what is the format?) ctrlpt = Numeric.array([[x, wm*xm, x], [-y, 0, y], [0, 0, 0], [1, wm, 1]], Numeric.Float) #build up complete arc from rotated segments @@ -281,7 +296,7 @@ class Arc(NurbsCurve): NurbsCurve.__init__(self, coefs, knots) class NurbsSurface: - def __init__(self, control_points, knots, display=False): + def __init__(self, control_points, knots, vknots, display=False): """ control_points is an array with the following shape: haha @@ -296,11 +311,15 @@ class NurbsSurface: """ shape = Numeric.asarray(control_points).shape - if not shape[2] == 3: raise ValueError, "control points must be specified with 3D coordinates" + #if not shape[2] == 3: raise ValueError, "control points must be specified with 3D coordinates" + #FIXME 2011-06-22 wow this is fucked up + #just get it over with and add uknots/vknots to the params if type(knots[0]) == list: uknots = knots[0] vknots = knots[1] + elif vknots: + uknots = knots else: uknots, vknots = knots, knots @@ -316,7 +335,9 @@ class NurbsSurface: #if dupe_count > degree: raise ValueError, "v-direction knot sequence has too many duplicate values" self.control_points = control_points + self.cntrl = control_points self.knots = knots + self.uknots, self.vknots = knots, vknots self.display = display def trans(self, matrix): @@ -335,8 +356,6 @@ def _extrude(curve, vector): #if you want weights for each point, set the weights to 1 #fill the v parametric direction with control points - print "coefs.shape: ", coefs.shape - print "control_points.shape: ", curve.control_points.shape coefs[:,:,0] = curve.control_points #calculate these points by the dot product between the given vector and the entire curve #i.e.: Numeric.dot(translate(vector), curve.control_points) @@ -394,6 +413,7 @@ def _revolve(curve, point = [0, 0, 0], vector = [1, 0, 0], theta = 2*math.pi): ) coefs[3,:,i] = coefs[3,:,i] * curve.control_points[3,i] + #FIXME 2011-06-22 parameters to NurbsSurface are wrong (vknots) surface = NurbsSurface(coefs, [arc.uknots, curve.uknots], display=curve.display) T = translate(point) diff --git a/visualizer.py b/visualizer.py index d04c105..055eff0 100644 --- a/visualizer.py +++ b/visualizer.py @@ -1,7 +1,6 @@ #!/usr/bin/env python # -*- coding: iso-8859-1 -*- #url: http://showmedo.com/videotutorials/video?name=1510030&fromSeriesID=151 -#url: http://steinsoft.net/index.php?site=Programming/Code%20Snippets/OpenGL/gluperspective import wx import sys @@ -9,29 +8,63 @@ from wx import glcanvas from OpenGL.GL import * from OpenGL.GLU import * +from nurbs import NurbsCurve, Circle +import Numeric +import numpy +array = numpy.array + +torusnurbpts = [ + 4.0, 0.0, 0.0, 4.0, 2.0, 0.0, 1.0, 2.0, 4.0, 0.0, 1.0, 2.0, + 8.0, 0.0, 0.0, 4.0, 4.0, 0.0,-1.0, 2.0, 2.0, 0.0,-1.0, 2.0, + 4.0, 0.0, 0.0, 4.0, 2.0,-2.0, 0.0, 2.0, 1.0,-1.0, 0.5, 1.0, + 2.0,-2.0, 0.5, 1.0, 4.0,-4.0, 0.0, 2.0, 2.0,-2.0,-0.5, 1.0, + 1.0,-1.0,-0.5, 1.0, 2.0,-2.0, 0.0, 2.0,-2.0,-2.0, 0.0, 2.0, + -1.0,-1.0, 0.5, 1.0,-2.0,-2.0, 0.5, 1.0,-4.0,-4.0, 0.0, 2.0, + -2.0,-2.0,-0.5, 1.0,-1.0,-1.0,-0.5, 1.0,-2.0,-2.0, 0.0, 2.0, + -4.0, 0.0, 0.0, 4.0,-2.0, 0.0, 1.0, 2.0,-4.0, 0.0, 1.0, 2.0, + -8.0, 0.0, 0.0, 4.0,-4.0, 0.0,-1.0, 2.0,-2.0, 0.0,-1.0, 2.0, + -4.0, 0.0, 0.0, 4.0,-2.0, 2.0, 0.0, 2.0,-1.0, 1.0, 0.5, 1.0, + -2.0, 2.0, 0.5, 1.0,-4.0, 4.0, 0.0, 2.0,-2.0, 2.0,-0.5, 1.0, + -1.0, 1.0,-0.5, 1.0,-2.0, 2.0, 0.0, 2.0, 2.0, 2.0, 0.0, 2.0, + 1.0, 1.0, 0.5, 1.0, 2.0, 2.0, 0.5, 1.0, 4.0, 4.0, 0.0, 2.0, + 2.0, 2.0,-0.5, 1.0, 1.0, 1.0,-0.5, 1.0, 2.0, 2.0, 0.0, 2.0, + 4.0, 0.0, 0.0, 4.0, 2.0, 0.0, 1.0, 2.0, 4.0, 0.0, 1.0, 2.0, + 8.0, 0.0, 0.0, 4.0, 4.0, 0.0,-1.0, 2.0, 2.0, 0.0,-1.0, 2.0, + 4.0, 0.0, 0.0, 4.0 + ] +circleknots = [0.0, 0.0, 0.0, 0.25, 0.50, 0.50, 0.75, 1.0, 1.0, 1.0] + +def sign(number): return cmp(number, 0) + class MyCanvasBase(glcanvas.GLCanvas): def __init__(self, parent): glcanvas.GLCanvas.__init__(self, parent, -1, attribList=[wx.glcanvas.WX_GL_DOUBLEBUFFER]) self.parent = parent #just for safe keeping self.init = False - # initial mouse position + + #initial mouse position self.lastx = self.x = 30 self.lasty = self.y = 30 + self.size = None + self.zoom = 1 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) + self.Bind(wx.EVT_MOUSEWHEEL, self.OnWheel) def OnEraseBackground(self, event): - pass # Do nothing, to avoid flashing on MSW. + pass #do nothing, to avoid flashing on MSW. def OnSize(self, event): size = self.size = self.GetClientSize() + self.width, self.height = event.GetSize() if self.GetContext(): self.SetCurrent() + self.InitGL() #glViewport(0, 0, size.width, size.height) #glViewport(0, 0, 300, 300) #self.OnPaint(event) @@ -57,34 +90,17 @@ class MyCanvasBase(glcanvas.GLCanvas): self.lastx, self.lasty = self.x, self.y self.x, self.y = evt.GetPosition() self.Refresh(False) - + + def OnWheel(self, evt): + if evt.GetWheelRotation() != 0: + self.zoom = self.zoom + (sign(evt.GetWheelRotation()) * 1) + print "wheel rotation: ", evt.GetWheelRotation() + print "zoom: ", self.zoom + self.InitGL() + self.OnDraw() + self.Refresh(False) class CubeCanvas(MyCanvasBase): - def old_InitGL(self): - # set viewing projection - glMatrixMode(GL_PROJECTION) - #glFrustum(-0.5, 0.5, -0.5, 0.5, 1.0, 3.0) - - width = self.parent.GetSize().width - height = self.parent.GetSize().height - - glLoadIdentity() - gluPerspective(45.0, width/float(height), 0.1, 100.0) - #gluPerspective(45.0, 1.0, 0.1, 100.0) - - # position viewer - glMatrixMode(GL_MODELVIEW) - glLoadIdentity() - - 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) - - glEnable(GL_DEPTH_TEST) - glEnable(GL_LIGHTING) - glEnable(GL_LIGHT0) def InitGL(self): glClearColor(0, 0, 0, 1) glClearDepth(1) @@ -94,29 +110,95 @@ class CubeCanvas(MyCanvasBase): glEnable(GL_COLOR_MATERIAL) - width = self.parent.GetSize().width - height = self.parent.GetSize().height - topleft_x, topleft_y, bottomright_x, bottomright_y = 0, 0, width, height + #natural_width = 800 + #natural_height = 600 + #glViewport(0, 0, natural_width, natural_height) + glViewport(0, 0, self.width, self.height) - glViewport(topleft_x, topleft_y, bottomright_x-topleft_x, bottomright_y-topleft_y) glMatrixMode(GL_PROJECTION) glLoadIdentity() - view_angle = 45 - ratio_w_h = float(float(float(bottomright_x)-float(topleft_x)) / float(float(bottomright_y)-float(topleft_y))) - clip_close = 0.1 - clip_far = 200 - gluPerspective(view_angle, ratio_w_h, clip_close, clip_far) + height = self.height + width = self.width + #natural_height = height + #natural_width = width + #view_angle = 60 # float(height) / natural_height * 45 + #ratio_w_h = float(width) / height + #clip_close = float(0.1) + #clip_far = 1000 + #gluPerspective(view_angle, ratio_w_h, clip_close, clip_far) + + centerx = 0 + centery = 0 + diam = 10 + #zoom2 = self.zoom + #if zoom2 == 0: zoom2 = 1 + #diam = zoom2 + # + #if zoom2 <= -1: + # diam = 1 - 1/zoom2 + + left = centerx - diam + right = centerx + diam + bottom = centery - diam + top = centery + diam + zNear = 1 + zFar = 200 + + #correct resizing, wrong circles + #glOrtho(-width/2, width/2, -height/2, height/2, zNear, zFar) + #glOrtho(-(width-diam)/2, (width+diam)/2, -(height-diam)/2, (height+diam)/2, zNear, zFar) + glOrtho(-width/2 - diam, width/2 + diam, -height/2 - diam, height/2 + diam, zNear, zFar) + + #correct circles, wrong resizing + #glOrtho(left, right, bottom, top, zNear, zFar) + #glOrtho(-10, 10, -10, 10, zNear, zFar) - glMatrixMode(GL_MODELVIEW) - glLoadIdentity() + #all wrong + #glOrtho(0, width, 0, height, zNear, zFar) + #centered, correct resizing, wrong circles + #glOrtho(-width, width, -height, height, zNear, zFar) + print "width: ", width + print "height: ", height - def old_OnDraw(self): - # clear color and depth buffers - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) - #glLoadIdentity() + ##glOrtho(0 - self.width, 0 + self.width, 0 - self.height, 0 + self.height, zNear, zFar) + glMatrixMode(GL_MODELVIEW) + glLoadIdentity() + nurb = gluNewNurbsRenderer() + gluNurbsProperty(nurb, GLU_SAMPLING_TOLERANCE, 1.) + gluNurbsProperty(nurb, GLU_DISPLAY_MODE, GLU_FILL) + + glNewList(1, GL_COMPILE) + + glMaterialfv(GL_FRONT, GL_SPECULAR, ( 1.0, 1.0, 1.0, 1.0 )) + glMaterialfv(GL_FRONT, GL_SHININESS, 100.0) + glMaterialfv(GL_FRONT, GL_DIFFUSE, ( 0.7, 0.0, 0.1, 1.0 )) + glEnable(GL_LIGHTING) + glEnable(GL_LIGHT0) + glEnable(GL_DEPTH_TEST) + glEnable(GL_AUTO_NORMAL) + glEnable(GL_NORMALIZE) + + #xcircle = Crv.Circle(radius=10) + #xsrf = Srf.Extrude(xcircle, [0, 0, 10]) + + circle = Circle(radius=10) + #circle = Crv.Line(p1=(0,0,0), p2=(1,1,1)) + #srf = Srf.Ruled(crv1, crv2) + #circle.cntrl[2][0] = -5 + srf = circle.extrude([0, 0, 10]) + #import pdb; pdb.set_trace(); + #srf.cntrl[3][0][0] = 5 + + gluBeginSurface(nurb) + gluNurbsSurface(nurb, srf.uknots, srf.vknots, Numeric.transpose(srf.cntrl, (1,2,0)), GL_MAP2_VERTEX_4) + gluEndSurface(nurb) + + glEndList() + + glNewList(2, GL_COMPILE) # draw six faces of a cube glBegin(GL_QUADS) glNormal3f( 0.0, 0.0, 1.0) @@ -148,144 +230,102 @@ class CubeCanvas(MyCanvasBase): 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() + glEndList() + + glNewList(3, GL_COMPILE) + + cntrl = [[-5., -7.5, 2.5, 0, -2.5, 7.5, 5.0], + [2.5, 5.0, 5.0, .0, -5.0, -5.0, 2.5]] + knots = [0., 0., 0., .2, .4, .6, .8, 1., 1., 1.] + + #crv = Crv.Crv(cntrl, knots) + #crv = Crv.Circle(radius=5) + crv = Circle(radius=10) + #crv = Crv.Line(p1=(0,0,0), p2=(10,10,10)) + + glPointSize(10.) + glDisable(GL_LIGHTING) + + #set color to white + glColor3f(1., 1., 1.) + + #draw white points + glBegin(GL_POINTS) + for i in range(crv.control_points.shape[1]): + w = crv.control_points[-1,i] + glVertex3f(crv.control_points[0, i]/w, crv.control_points[1, i]/w, crv.control_points[2, i]/w) + glEnd() + + #draw the polygon connecting the points + glBegin(GL_LINE_STRIP) + for i in range(crv.control_points.shape[1]): + w = crv.control_points[-1,i] + glVertex3f(crv.control_points[0, i]/w, crv.control_points[1, i]/w, crv.control_points[2, i]/w) + glEnd() + + #circle + glColor3f(1., 0., 0.) + nurb2 = gluNewNurbsRenderer() + gluNurbsProperty(nurb2, GLU_SAMPLING_TOLERANCE, 1) + + gluBeginCurve(nurb2) + gluNurbsCurve(nurb2, crv.knots, Numeric.transpose(crv.control_points), GL_MAP1_VERTEX_4) + gluEndCurve(nurb2) + + #circular_surface = crv.extrude([0, 0, 10]) + #gluBeginSurface(nurb2) + #gluNurbsSurface(nurb2, circular_surface.uknots, circular_surface.vknots, Numeric.transpose(circular_surface.control_points, (1,2,0)), GL_MAP2_VERTEX_4) + #gluEndSurface(nurb2) + + #everything else should be yellow + glColor3f(1., 1., 0.) + + glEndList() - #if self.size is None: - # self.size = self.GetClientSize() - #w, h = self.size - #w = max(w, 1.0) - #h = max(h, 1.0) - #xScale = 180.0 / w - #yScale = 180.0 / h - #glRotatef((self.y - self.lasty) * yScale, 1.0, 0.0, 0.0); - #glRotatef((self.x - self.lastx) * xScale, 0.0, 1.0, 0.0); - - glPushMatrix() - glTranslate(0.0, 0.0, -2.0) - glPopMatrix() - self.SwapBuffers() def OnDraw(self): glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) - - self.InitGL() + glMatrixMode(GL_MODELVIEW) glLoadIdentity() - - glTranslatef(0,0,-5) - glRotatef(50, 0, 1, 0) - glColor4f(1, 0, 0, 1) + zoom2 = self.zoom + if zoom2 == 0: zoom2 = 1 + if zoom2 <= -1: + zoom2 = -1/float(zoom2) + glScalef(zoom2, zoom2, 1) + print "zoom factor is: ", zoom2 - # 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) + #move it back a bit + glTranslatef(0, 0, -15) - 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) + #mouse click rotation + glRotatef(self.lastx, 0.0, 1.0, 0.0) + glRotatef(self.lasty, 1.0, 0.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) + glCallList(1) + glCallList(3) - 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) + factor = 5 + glScalef(factor, factor, factor) + glCallList(2) - 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() - - glFlush() self.SwapBuffers() - - #glPushMatrix() - #glTranslate(0.0, 0.0, -2.0) - #glPopMatrix() - -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]) - glLightModelfv(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) - # position viewer - glTranslatef(0.0, 0.0, -2.0); - # - glutInit(sys.argv) - - 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.y - self.lasty), 0.0, 0.0, 1.0); - glRotatef((self.x - self.lastx), 1.0, 0.0, 0.0); - # push into visible buffer - self.SwapBuffers() - - + class MainWindow(wx.Frame): - def __init__(self, parent = None, id = -1, title = "PyOpenGL Example 1"): - # Init + def __init__(self, parent = None, id = -1, title = "lolcad"): wx.Frame.__init__( - self, parent, id, title, size = (600,600), + self, parent, id, title, size = (480,320), style = wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE ) - # TextCtrl - # self.control = wx.TextCtrl(self, -1, style = wx.TE_MULTILINE) - - #self.control = ConeCanvas(self) + #TextCtrl + #self.control = wx.TextCtrl(self, -1, style = wx.TE_MULTILINE) box = wx.BoxSizer(wx.HORIZONTAL) @@ -297,7 +337,6 @@ class MainWindow(wx.Frame): self.SetSizer(box) #self.SetAutoLayout(True) #default - # Show self.Show(True) def OnAbout(self,event): @@ -306,13 +345,12 @@ class MainWindow(wx.Frame): wx.MessageBox(message, caption, wx.OK) def OnExit(self,event): - self.Close(True) # Close the frame. + self.Close(True) #close the frame app = wx.PySimpleApp() frame = MainWindow() app.MainLoop() -# destroying the objects, so that this script works more than once in IDLEdieses Beispiel +#destroying the objects, so that this script works more than once in IDLEdieses Beispiel #del frame #del app - |