#!/usr/bin/python
from wxPython.wx import *
ID_ABOUT = 101
ID_EXIT = 102
class MyFrame(wxFrame):
def __init__(self, parent, ID, title):
wxFrame.__init__(self, parent, ID, title, wxDefaultPosition, wxSize(200, 150))
self.CreateStatusBar()
self.SetStatusText("This is the statusbar")
menu = wxMenu()
menu.Append(ID_ABOUT, "&About",
"More information about this program")
menu.AppendSeparator()
menu.Append(ID_EXIT, "E&xit", "Terminate the program")
menuBar = wxMenuBar()
menuBar.Append(menu , "&File");
self.SetMenuBar(menuBar)
EVT_MENU(self, ID_ABOUT, self.OnAbout)
EVT_MENU(self, ID_EXIT, self.TimeToQuit)
def OnAbout(self, event):
dlg = wxMessageDialog(self, "This sample program shows off\n"
"frames, menus, statusbars, and this\n"
"message dialog.",
"About Me", wxOK | wxICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
def TimeToQuit(self, event):
self.Close(true)
class MyApp(wxApp):
def OnInit(self):
frame = MyFrame(NULL , -1 , "Hello from wxPython")
frame.Show(true)
self.SetTopWindow(frame)
return true
app = MyApp(0)
app.MainLoop()
produces
genjix@linux:~/media/programming/python> ./wx.py
Traceback (most recent call last):
File "./wx.py", line 3, in ?
from wxPython.wx import *
File "/usr/lib/python2.3/site-packages/wxPython/__init__.py", line 10, in ?
import _wx
File "/usr/lib/python2.3/site-packages/wxPython/_wx.py", line 3, in ?
from _core import *
File "/usr/lib/python2.3/site-packages/wxPython/_core.py", line 15, in ?
import wx._core
File "/home/genjix/media/programming/python/wx.py", line 3, in ?
from wxPython.wx import *
ImportError: No module named wx
genjix@linux:~/media/programming/python>
I didn't previously have wxPython-GTK rpm installed (SUSE here), so I installed it, but ignored my missing wxGTK-GL dependencies.
I can successfully compile a wxWidgets app (C++).
Thanks.