Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canvas show=True doesn't work #39

Closed
rougier opened this issue Aug 26, 2013 · 7 comments
Closed

Canvas show=True doesn't work #39

rougier opened this issue Aug 26, 2013 · 7 comments

Comments

@rougier
Copy link
Contributor

rougier commented Aug 26, 2013

Take the examples/atom.py and tries:

app.Canvas.init(self, show=True)

The window is immediately shown while my canvas initalization is not yet finished. Showing the canvas should be deferred until the app is ran.

@almarklein
Copy link
Member

Yeah, I found this too. show=True only really works when you are not subclassing Canvas.

How do other toolkits deal with this? I would be surprised if the deffered the showing till the app is run.

A solution (I think) is to do the Canvas.init(self) at the end of your new init.

@almarklein
Copy link
Member

atom.py now demonstrates how you would do this. Dereferencing the showing until the app is run is non-trivial at best.

@rougier rougier reopened this Aug 29, 2013
@rougier
Copy link
Contributor Author

rougier commented Aug 29, 2013

I think it is not really fixed even though the atom example show a workaround.

@almarklein
Copy link
Member

But I do not think it is a bug of vispy. This behaviour is inherent to how window creation works.

In theory, we could keep a list of windows-to-show on the app. The Canvas can add itself to the list. On app.run() all canvas objects in the list are shown. However, this will fail if a Canvas is created while the mainloop is running, for instance when a button is pressed and a popup with a visualization is shown.

@rougier
Copy link
Contributor Author

rougier commented Aug 29, 2013

But this means we cannot make the windows visible by default, no ?

On Aug 29, 2013, at 10:22 AM, Almar Klein notifications@github.com wrote:

But I do not think it is a bug of vispy. This behaviour is inherent to how window creation works.

In theory, we could keep a list of windows-to-show on the app. The Canvas can add itself to the list. On app.run() all canvas objects in the list are shown. However, this will fail if a Canvas is created while the mainloop is running, for instance when a button is pressed and a popup with a visualization is shown.


Reply to this email directly or view it on GitHub:
#39 (comment)

@almarklein
Copy link
Member

We can, but when subclassing Canvas, you need to take into account that the call to Canvas.__init__(self, **kwargs) may invoke a call to some of the event handlers. So you probably want to do that after you've initialized stuff (as shown in atom.py).

And this should also just work:

MyCanvas(app.Canvas):
    def __init__(self):
        app.Canvas.__init__(self) # No show here
        .... init stuff
        self.show()

    def on_paint(self):
        ... etc.

And so does this:

canvas = Canvas(show=True)

@canvas.connect
def on_paint(event):
    ....

@rougier
Copy link
Contributor Author

rougier commented Aug 29, 2013

Ok, great. I think we can close it.

Nicolas

On Aug 29, 2013, at 11:24 AM, Almar Klein notifications@github.com wrote:

We can, but when subclassing Canvas, you need to take into account that the call to Canvas.__init__(self, **kwargs) may invoke a call to some of the event handlers. So you probably want to do that after you've initialized stuff (as shown in atom.py).

And this should also just work:

MyCanvas(app.Canvas):
def init(self):
app.Canvas.init(self) # No show here
.... init stuff
self.show()

   def on_paint(self):
       ... etc.

And so does this:

canvas = Canvas(show=True)

@canvas.connect
def on_paint(event):
....


Reply to this email directly or view it on GitHub:
#39 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants