fnokke
fnokke

Reputation: 1161

Running wxpython app in cygwin/X

I have installed and tried both wxpython-3.0 and wxpython-2.8 for python2.7 from the standard cygwin repos (64-bit, Win 7). However when I start the Cygwin X server and try to run the most simple "Hello World" script from wxPython tutorials:

# test.py
import wx

app = wx.App(False)  # Create a new app, don't redirect stdout/stderr to a window.
frame = wx.Frame(None, wx.ID_ANY, "Hello World") # A Frame is a top-level window.
frame.Show(True)     # Show the frame.
app.MainLoop()

I get a Gtk-WARNING **: Screen for GtkWindow not set which eventually ends in a segmentation fault.

The DISPLAY variable is set to :0 (export DISPLAY=:0) and corresponds to the started X server.

Is wxPython broken in cygwin or is some other procedure necessary prior to launching a script using wxPython?

Upvotes: 7

Views: 522

Answers (2)

lamorwe
lamorwe

Reputation: 36

I tested this and got it working for my cygwin64 installation. I used

  • python v2.7.14 and
  • cygwin package python-2-wx version 3.0.2.0-3

Both installed via the cygwin installer. I also have the python-2-wx2.8 in my cygwin install, and I can select which one is to be used by creating the file /usr/lib/python2.7/site-packages/wx.pth containing only one line specifying the relative path to the package to be imported by the "import wx" line:

wx-3.0-gtk3

or

wx-2.8-gtk2-unicode

When I use the later (wx-2.8-gtk2-unicode) I get the same error as you mention, "assertion 'GDK_IS_DISPLAY (display)' failed", but when I use wx-3.0-gtk3 the errors disappear and the script runs fine and I can see the graphics in my X-window.

Upvotes: 2

Patrick Kelly
Patrick Kelly

Reputation: 1381

Try starting your X server with the startxwin command instead of xinit.

startxwin &

export DISPLAY=:0.0

./test.py

I was able to get your test code running with this sequence.

Upvotes: 0

Related Questions