gdk_X11_get_default_xdisplay intermittently returns bad Display pointer



I've got some python code in which I'm trying to use
gdk_X11_get_default_xdisplay but it fails intermittently returning a
bad pointer. I don't believe that this problem has anything to do with
python. Have others experienced this and if so are there any
workarounds? Is this a know issue? I'm running
gtk2-2.14.7-1.fc10.x86_64 on Fedora 10.

# Load in pygtk and gtk

import pygtk
pygtk.require('2.0')
import gtk
import ctypes
import sys

libgdk = ctypes.cdll.LoadLibrary("libgdk-x11-2.0.so.0")

# Define the main window

class Whc:
    def __init__(self):
        # Window and framework
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.connect("destroy", self.destroy)

        # A Button, with an action
        # Add it to the geometry
        # show the button
        self.button = gtk.Button("First Button")
        self.button.connect("clicked", self.hello, None)
        self.window.add(self.button)
        self.button.show()

        # Show the window
        self.window.show()
        try:
            xdisplay = libgdk.gdk_x11_get_default_xdisplay()
            print "xdisplay 0x%x" % (xdisplay)
            if xdisplay < 0:
                print "error"
                sys.exit(-1)
        except Exception, ex:
            print ex

# Callback function for use when the button is pressed

    def hello(self, widget, data=None):
        print "Hello World"

# Destroy method causes appliaction to exit
# when main window closed

    def destroy(self, widget, data=None):
        gtk.main_quit()

# All PyGTK applicatons need a main method - event loop

    def main(self):
        gtk.main()

if __name__ == "__main__":
    base = Whc()
    base.main()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]