I am struggling to get the bellow code (MWE) working.
Expected behavior: python quits after closing all windows
Observed behavior: python keeps running
Has anybody a clue why python does not quit?
#!/usr/bin/env python
import wx
from vispy import scene
class Canvas(scene.SceneCanvas):
def __init__(self, *args, **kwargs):
scene.SceneCanvas.__init__(self, *args, **kwargs,)
class VispyFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, -1, "Vispy Frame", wx.DefaultPosition, size=(500, 500))
self.Bind(wx.EVT_CLOSE, self.on_close)
self.Bind(wx.EVT_SHOW, self.on_show)
self.canvas = Canvas(app="wx", parent=self)
def on_close(self, event):
print("close")
self.canvas.app.quit()
self.canvas.close()
self.Destroy()
def on_show(self, event):
print("show")
self.canvas.show()
class MainFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, "WX Frame")
self.panel = wx.Panel(self, -1)
button = wx.Button(self.panel, label="VISPY")
self.Bind(wx.EVT_BUTTON, self.newwindow, button)
def newwindow(self, event):
secondWindow = VispyFrame(parent=self.panel)
secondWindow.Show()
app = wx.App(False)
frame = MainFrame()
frame.Show(True)
app.MainLoop()
For anyone finding this later, the github issue filed by @gkft walks through a few things that ended up working.
https://github.com/vispy/vispy/issues/1965