Skip to content

Commit

Permalink
Fixed a few examples on OS X
Browse files Browse the repository at this point in the history
`self.show(True)` or `app.Canvas.__init__(self, show=True)` should
only be called after the rest of the initialisation code has run.
  • Loading branch information
nippoo committed Mar 24, 2015
1 parent 2f46ed2 commit f92eab0
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 8 deletions.
4 changes: 3 additions & 1 deletion examples/basics/visuals/cube.py
Expand Up @@ -19,7 +19,7 @@ def __init__(self):
self.theta = 0
self.phi = 0

app.Canvas.__init__(self, 'Cube', keys='interactive', show=True,
app.Canvas.__init__(self, 'Cube', keys='interactive',
size=(400, 400))

# Create a TransformSystem that will tell the visual how to draw
Expand All @@ -29,6 +29,8 @@ def __init__(self):

self._timer = app.Timer('auto', connect=self.on_timer, start=True)

self.show(True)

def on_draw(self, event):
gloo.set_viewport(0, 0, *self.size)
gloo.clear('white')
Expand Down
3 changes: 2 additions & 1 deletion examples/basics/visuals/image_transforms.py
Expand Up @@ -56,12 +56,13 @@ def __init__(self):

vispy.app.Canvas.__init__(self, keys='interactive')
self.size = (800, 800)
self.show()

for img in self.images:
img.tr_sys = TransformSystem(self)
img.tr_sys.visual_to_document = img.transform

self.show(True)

def on_draw(self, ev):
gloo.clear(color='black', depth=True)
gloo.set_viewport(0, 0, *self.size)
Expand Down
3 changes: 2 additions & 1 deletion examples/basics/visuals/image_visual.py
Expand Up @@ -22,12 +22,13 @@ def __init__(self):
self.image_transform = STTransform(scale=(7, 7), translate=(50, 50))
vispy.app.Canvas.__init__(self, keys='interactive')
self.size = (800, 800)
self.show()

# Create a TransformSystem that will tell the visual how to draw
self.tr_sys = TransformSystem(self)
self.tr_sys.visual_to_document = self.image_transform

self.show(True)

def on_draw(self, ev):
gloo.clear(color='black', depth=True)
gloo.set_viewport(0, 0, *self.size)
Expand Down
4 changes: 3 additions & 1 deletion examples/basics/visuals/line.py
Expand Up @@ -34,7 +34,7 @@
class Canvas(app.Canvas):
def __init__(self):
app.Canvas.__init__(self, keys='interactive',
size=(800, 800), show=True)
size=(800, 800))
# Create several visuals demonstrating different features of Line
self.lines = [
# agg-mode lines:
Expand Down Expand Up @@ -83,6 +83,8 @@ def __init__(self):
visual.tr_sys = visuals.transforms.TransformSystem(self)
visual.tr_sys.visual_to_document = visual.transform

self.show(True)

def on_draw(self, event):
gloo.clear('black')
gloo.set_viewport(0, 0, *self.size)
Expand Down
4 changes: 3 additions & 1 deletion examples/basics/visuals/line_plot.py
Expand Up @@ -24,9 +24,11 @@ def __init__(self):
self.line = visuals.LinePlotVisual(pos, color='w', edge_color='w',
face_color=(0.2, 0.2, 1))
app.Canvas.__init__(self, keys='interactive',
size=(800, 800), show=True)
size=(800, 800))
self.tr_sys = visuals.transforms.TransformSystem(self)

self.show(True)

def on_draw(self, event):
gloo.clear('black')
gloo.set_viewport(0, 0, *self.size)
Expand Down
3 changes: 2 additions & 1 deletion examples/basics/visuals/line_transform.py
Expand Up @@ -72,13 +72,14 @@ def __init__(self):

app.Canvas.__init__(self, keys='interactive')
self.size = (800, 800)
self.show()

for line in self.lines:
tr_sys = visuals.transforms.TransformSystem(self)
tr_sys.visual_to_document = line.transform
line.tr_sys = tr_sys

self.show(True)

def on_draw(self, ev):
gloo.clear('black', depth=True)
gloo.set_viewport(0, 0, *self.size)
Expand Down
4 changes: 3 additions & 1 deletion examples/demo/gloo/imshow.py
Expand Up @@ -95,7 +95,7 @@ def func(x, y):

class Canvas(app.Canvas):
def __init__(self):
app.Canvas.__init__(self, show=True, size=(512, 512),
app.Canvas.__init__(self, size=(512, 512),
keys='interactive')
self.image = Program(img_vertex, img_fragment, 4)
self.image['position'] = (-1, -1), (-1, +1), (+1, -1), (+1, +1)
Expand All @@ -113,6 +113,8 @@ def __init__(self):

set_clear_color('black')

self.show(True)

def on_resize(self, event):
width, height = event.size
set_viewport(0, 0, *event.size)
Expand Down
4 changes: 3 additions & 1 deletion examples/demo/gloo/imshow_cuts.py
Expand Up @@ -111,7 +111,7 @@ def func(x, y):

class Canvas(app.Canvas):
def __init__(self):
app.Canvas.__init__(self, show=True, size=(512, 512),
app.Canvas.__init__(self, size=(512, 512),
keys='interactive')

self.image = Program(image_vertex, image_fragment, 4)
Expand All @@ -137,6 +137,8 @@ def __init__(self):
set_state(clear_color='white', blend=True,
blend_func=('src_alpha', 'one_minus_src_alpha'))

self.show(True)

def on_resize(self, event):
set_viewport(0, 0, *event.size)

Expand Down

0 comments on commit f92eab0

Please sign in to comment.