mild improvements to demo python sequence view
authorDiane Trout <diane@caltech.edu>
Sun, 5 Mar 2006 23:21:20 +0000 (23:21 +0000)
committerDiane Trout <diane@caltech.edu>
Sun, 5 Mar 2006 23:21:20 +0000 (23:21 +0000)
gl.py can successfully display a glSequence in a glut window.
Not terribly exciting, but still its python driving a mussa view

py/gl.py

index 43d29f64ada38c4c6e511364e8a0aee8cef704da..4f9ca0d1e0c7dd647d1aea2132a6851dd6f3e024 100644 (file)
--- a/py/gl.py
+++ b/py/gl.py
@@ -1,18 +1,35 @@
 """Can we show a mussa gl object?
 """
+import sys
+
 from OpenGL.GLUT import *
 from OpenGL.GL import *
 import mussa
 
-def main():
-  seq = mussa.Sequence()
-  s = "AAGGCCTTAAGGCCTT" 
-  seq = mussa.Sequence(s)
-  assert s == seq.size() == len(seq)
-  glseq = mussa.GlSequence(seq)
-
-  glutInit(sys.argv)
   
+class pyMussaGL:
+  def __init__(self):
+    seq = mussa.Sequence()
+    s = "AAGGCCTTAAGGCCTT" * 100
+    seq = mussa.Sequence(s)
+    assert len(s) == seq.size() == len(seq)
+    self.glseq = mussa.GlSequence(seq)
+
+    glutInit(sys.argv)
+    glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH )
+    glutCreateWindow('mussa')
+    glClearColor(1,1,1,0)
+
+    glOrtho(-50, len(seq)+50, -50, 50, -50, 50)
+
+    glutDisplayFunc(self.display)
+    print "init done"
   
+  def display(self):
+    glClear(GL_COLOR_BUFFER_BIT)
+    self.glseq.draw()
+    glutSwapBuffers()
+
 if __name__ == "__main__":
-  main()
+  p = pyMussaGL()
+  glutMainLoop()