开发者

why does my pygtk application crash when copying text on a clipboard?

I'm writing a python application using pygtk. I have a main thread who occasionally calls another thread that is supposed to build a string and then copy it on the clipboard before dying. My "slave" thread looks pretty much like this:

class Slave(threading.Thread):
    def run(self):
        s = build_string()
        c = gtk.Clipboard()
        c.set_text(s)

Unfortunately my app crashes one-third of the time, showing a message like this:

python: xcb_io.c:221: poll_for_event: Assertion `(((long) (event_sequence) - (long) (dpy->request)) <= 0)' failed.
cloudapp.py: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.0.

Any idea? Could it be a threading problem? I tried initializing the clipboard inside of the Slave.init, putting the string on a TextBuffer and then cal开发者_开发问答ling tb.copy_clipboard(c), I tried everything, none of them worked.


You can't interact with Gtk from threads without taking some necessary precautions. Check this PyGTK FAQ entry.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜