Search code examples
pythonwxpythonframe

How to make wxPython frame stands long?


I am using wxPython to display a graphical output in a wx.Frame. with in a class. Here is my code:

class X():
    ......

    def uniform_output(self):
        ......
        self.GraphicalOutput()


    def GraphiclaOutput(self):
        self._app = wx.App()
        self._frame = wx.Frame(None, self._app, 0, 'Graphical Output', size = (800, 600))
        self._frame.Show()
        self._app.MainLoop()

When I run my code, I create an instance of class X, and it will call its function GraphicalOutput(). However, when the graphical frame should show up, it merely flashed on the screen and disappeared.

May I know how to make the frame stay on the screen until I turn it off?

Thanks.


Solution

  • Seems the parameter is not correct when you create the Frame. Did you see any error in the console?

    Maybe you can try this:

    frame = wx.Frame(None, -1, 'Graphical Output', size = (800, 600))