Code Monkey home page Code Monkey logo

Comments (7)

almarklein avatar almarklein commented on May 17, 2024

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.

from vispy.

almarklein avatar almarklein commented on May 17, 2024

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

from vispy.

rougier avatar rougier commented on May 17, 2024

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

from vispy.

almarklein avatar almarklein commented on May 17, 2024

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.

from vispy.

rougier avatar rougier commented on May 17, 2024

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

On Aug 29, 2013, at 10:22 AM, Almar Klein [email protected] 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)

from vispy.

almarklein avatar almarklein commented on May 17, 2024

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):
    ....

from vispy.

rougier avatar rougier commented on May 17, 2024

Ok, great. I think we can close it.

Nicolas

On Aug 29, 2013, at 11:24 AM, Almar Klein [email protected] 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)

from vispy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.