Advertisement Jump to content
Sign in to follow this  

wxPython help

This topic is 4967 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


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.SetStatusText("This is the statusbar")

		menu = wxMenu()
		menu.Append(ID_ABOUT, "&About",
                    "More information about this program")
		menu.Append(ID_EXIT, "E&xit", "Terminate the program")

		menuBar = wxMenuBar()
		menuBar.Append(menu , "&File");


		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)

	def TimeToQuit(self, event):

class MyApp(wxApp):
	def OnInit(self):
		frame = MyFrame(NULL , -1 , "Hello from wxPython")
		return true

app = MyApp(0)

genjix@linux:~/media/programming/python> ./
Traceback (most recent call last):
  File "./", line 3, in ?
    from wxPython.wx import *
  File "/usr/lib/python2.3/site-packages/wxPython/", line 10, in ?
    import _wx
  File "/usr/lib/python2.3/site-packages/wxPython/", line 3, in ?
    from _core import *
  File "/usr/lib/python2.3/site-packages/wxPython/", line 15, in ?
    import wx._core
  File "/home/genjix/media/programming/python/", line 3, in ?
    from wxPython.wx import *
ImportError: No module named wx
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.

Share this post

Link to post
Share on other sites
ok so I have re-installed wxPython from src, but make install doesn't seem to have put wxPython modules where they were last (any suggestions?), so I have put them in the same directory as my python files (wxPython directory).

how can I include them? I thought a simple from wxPython.wx import * would suffice.

Share this post

Link to post
Share on other sites
Original post by Kylotan
Try import wx, instead of from wxPython.wx import *.

nope. :(


how can i include the wx files in the current directory?

where should they be on my system?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!