First wxpython program: why doesn't window persist

Re: [wxpython-users] First wxpython program: why doesn’t window persist
change the last line

From:

app.MainLoop

to:

app.MainLoop()

It should then work.

Thursday, May 15, 2008, 12:53:08 PM, you wrote:

wxPython beginner here. I’m trying a very simple wxPython program, to do

nothing more than open a text window displaying text from a small file.

I see the window flash up, but the program terminates. My expectation was that

the window would stay open, and then when I hit the close button, my program

would terminate. Where am I going wrong?

the program:

import wx

class TextFrame(wx.Frame):

def __init__(self, filename):
    wx.Frame.__init__(self, None, -1,
                      title=filename, style=wx.DEFAULT_FRAME_STYLE)
    panel = wx.Panel(self, -1)
    lines = file(filename).readlines()
    tc = wx.TextCtrl(panel, -1, style=wx.TE_MULTILINE)
    for line in lines:
        tc.AppendText(line)

if name == “main”:

filename = "sample.txt"
app = wx.PySimpleApp()
frame = TextFrame(filename)
frame.Show()
app.MainLoop

wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

TC> http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

···

Best regards,

Bruce mailto:bruce@blazertech.net

Bruce at blazer <bruce <at> blazertech.net> writes:

change the last line From:

app.MainLoop

to:

app.MainLoop()

Thanks. Man, I really should have seen that.