wxPython beginners problem

s0suk3 at gmail.com s0suk3 at gmail.com
Fri Aug 15 14:01:11 EDT 2008


On Aug 15, 11:31 am, Ivan Reborin <ireborin at gmail.com> wrote:
> Hello all,
>
> I'm new to python, new as newbies get, so please, don't take wrongly
> if this seems like a stupid or overly simple question.
>
> I'm going through examples in a book I have ("Beginning python", by
> Hetland Marcus) and I just started doing wxPython examples.
>
> But every sample I try, for example:
>
> import wx
> app = wx.App()
> win = wx.Frame(None, title="Simple editor")
> loadButton = wx.Button(win, label='Open')
> saveButton = wx.Button(win, label='Save')
> win.Show
> app.MainLoop()
>

There are a couple of things you're missing. Here is the fix:

import wx

# First of all, I'd recommend you to pass False as
# the 'redirect' parameter, so that any errors appear
# on the console
app = wx.App(redirect=False)

win = wx.Frame(None, title="Simple editor")
loadButton = wx.Button(win, label='Open')
saveButton = wx.Button(win, label='Save')

# Now you need to set the frame as the top-level
# window

app.SetTopWindow(frame)

# In the line
#
#  win.Show
#
# Python recognizes this as a method, but you're
# not calling it, so its value is discarded. It's
# a meaningless, albeit legal statement.

win.Show()

# Now, let the fun begin
app.MainLoop()

# Sebastian




More information about the Python-list mailing list