trouble with wxPython intro
7stud
bbxx789_05ss at yahoo.com
Thu May 31 03:56:01 EDT 2007
On May 30, 11:41 pm, Anthony Irwin <nos... at noemailhere.nowhere> wrote:
> Daniel Gee wrote:
> > I'm trying to learn WxPython with the tutorial:
> >http://wiki.wxpython.org/Getting_Started
>
I'm a wxPython beginner too, but instead of Anthony Irwin's
suggestions, I think you should delete these two lines:
ID_ABOUT=101
ID_EXIT=110
and use:
wx.ID_ABOUT
wx.ID_EXIT
throughout the body of your program. As far as I can tell, there is
no reason for you to be manually setting your own id's (is there
ever?). Instead, you can use the ids in the wx module.
In addition, I suggest you never use wx.PySimpleApp(). If you create
your own app class, you can send the error messages to the console.
Instead of always seeing a window that flashes at you briefly and
being left with no clue what went wrong, you can at least see an error
message and a line number in the console. Here's how you would do
that:
-----------------
import wx
class MyFrame(wx.Frame):
def __init__(self, mytitle):
wx.Frame.__init__(self, None, title= mytitle)
class MyApp(wx.App):
def __init__(self):
wx.App.__init__(self, redirect=False)
app = MyApp()
window = MyFrame("Testing")
window.Show()
app.MainLoop()
------------------
By setting redirect=False in wx.App.__init__(), the errors will be
sent to the console.
More information about the Python-list
mailing list