David Guijo
David Guijo

Reputation: 23

How to create and destroy wx.App?

I'm doing a new project in Python with MacOs X using interfaces(wxPython for the interfaces). Firstly I create an interface for selecting between differents time series algorithms, then, when the algorithm ends, I want to show in a graph the new time serie.

For this graph (matplotlib + wxPython), I want to use another window different to the other one.

When I display the graph windows and I close it, everything is ok, but the problems arises now. I want to close the main windows (which displays the differents time series algorithms), but I have never get it closed... When I force to close that windows, I get 139 and 143 pythos errors.

I really don't know why that happens.

The main windows is being created by this code:

app = wx.App()
frame = interface.MyFrame1(None)
frame.Show()
app.MainLoop()

MyFrame1 contains everything needed for the time series algorithms.

And the graph windows is being created by this code:

app2 = wx.App()
frame = graphs.BarsFrame()
frame.Show()
app2.MainLoop()

BarsFrame is the class that contains everything needed for ploting.

I create the second frame as a child of the other one, so, when I close the main interface, the graph get closed, but the program still running in background.

Thank you so much, I have tried lot of things, such as, ploting in the main interface, but I haven't get success...

Upvotes: 1

Views: 262

Answers (1)

nepix32
nepix32

Reputation: 3177

Are you creating 2 wx.App instances? Do not do that. Your example should be something so simple as having a main wx.Frame and a child plot frame.

Do as follows:

app = wx.App()
# main frame
frame = interface.MyFrame1(None)
frame.Show()

# plot frame, the correct parenting is important, this is not shown in your example
frame2 = graphs.BarsFrame(parent=frame)
frame2.Show()

app.MainLoop()

Upvotes: 2

Related Questions