How to import wx on Ubuntu 16.04
In Ubuntu 16.04 and later open the terminal and type:
sudo apt install python-wxgtk3.0 python-wxgtk3.0-dev
Then check if wx works in Python 2.x as follows:
$ python >>> import wx
Example code
-
Save the following code as
wxPython-window.py
-
Make it executable.
-
Change directories using
cd
to the parent directory of wxPython-window.py -
Run the code with
./wxPython-window.py
#!/usr/bin/python import wx app = wx.App() frame = wx.Frame(None, -1, 'win.py') frame.Show() app.MainLoop()