Created
June 30, 2009 22:25
-
-
Save nzjrs/138478 to your computer and use it in GitHub Desktop.
Demo for testing gtk.Curve
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Demo for testing gtk.Curve | |
# John Stowers 2009 | |
import random | |
import gtk | |
class UI: | |
TYPES = (gtk.CURVE_TYPE_LINEAR, gtk.CURVE_TYPE_SPLINE, gtk.CURVE_TYPE_FREE) | |
N = 1000 | |
def __init__(self): | |
self.c = gtk.Curve() | |
self.t = 0 | |
vb = gtk.VBox() | |
vb.pack_start(self.c, True, True) | |
b = gtk.Button("Add") | |
b.connect("clicked", self._on_add) | |
vb.pack_start(b, False, False) | |
b = gtk.Button("Type") | |
b.connect("clicked", self._on_type) | |
vb.pack_start(b, False, False) | |
w = gtk.Window() | |
w.add(vb) | |
w.show_all() | |
w.connect("delete-event", lambda *args: gtk.main_quit()) | |
def _on_add(self, *args): | |
d = [random.random() for i in range(self.N)] | |
self.c.set_vector(d) | |
self.c.set_curve_type( self.TYPES[self.t] ) | |
def _on_type(self, *args): | |
self.t = (self.t + 1) % len(self.TYPES) | |
self.c.set_curve_type( self.TYPES[self.t] ) | |
print "TYPE = ", self.TYPES[self.t] | |
if __name__ == "__main__": | |
u = UI() | |
gtk.main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment