Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6577841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:41:29+00:00 2026-05-25T15:41:29+00:00

I have a project that runs Python 2.7, PyGTK 2.24, and the most recent

  • 0

I have a project that runs Python 2.7, PyGTK 2.24, and the most recent version of PyGST.

I am getting a weird intermittent error in the following code. With the first, longer error, the video will play just fine, and the error will only appear AFTER I close the video window. The second prevents the window from opening at all.

import pygtk
pygtk.require('2.0')
import gtk, pango
import pygst
pygst.require('0.10')
import gst
import Trailcrest
import os, sys

class Video:

    def __init__(self):

        def on_message(bus, message): 
            if message.type == gst.MESSAGE_EOS: 
                # End of Stream 
                player.set_state(gst.STATE_NULL) 
            elif message.type == gst.MESSAGE_ERROR: 
                player.set_state(gst.STATE_NULL) 
                (err, debug) = message.parse_error() 
                print "Error: %s" % err, debug

        def on_sync_message(bus, message):
            if message.structure is None: 
                return False 
            if message.structure.get_name() == "prepare-xwindow-id":
                if sys.platform == "win32":
                    win_id = videowidget.window.handle
                else:
                    win_id = videowidget.window.xid
                assert win_id
                imagesink = message.src 
                imagesink.set_property("force-aspect-ratio", True)
                imagesink.set_xwindow_id(win_id) 

        win = gtk.Window()
        win.set_resizable(False)
        win.set_has_frame(False)
        win.set_position(gtk.WIN_POS_CENTER)

        fixed = gtk.Fixed()
        win.add(fixed)
        fixed.show()

        videowidget = gtk.DrawingArea()
        fixed.put(videowidget, 0, 0)
        videowidget.set_size_request(640, 480)
        videowidget.show()

        # Setup GStreamer 
        player = gst.element_factory_make("playbin", "MultimediaPlayer")
        bus = player.get_bus() 
        bus.add_signal_watch() 
        bus.enable_sync_message_emission() 
        #used to get messages that GStreamer emits 
        bus.connect("message", on_message) 
        #used for connecting video to your application 
        bus.connect("sync-message::element", on_sync_message)
        player.set_property("uri", "file://" + os.getcwd() + "/VID/SEQ-GAME-OPEN.ogv") 
        player.set_state(gst.STATE_PLAYING)

        win.show()

def main():
    gtk.gdk.threads_init()
    gtk.main()
    return 0

if __name__ == "__main__":
    Video()
    main()

The program ‘Video.py’ received an X Window System error. This
probably reflects a bug in the program. The error was ‘BadIDChoice
(invalid resource ID chosen for this connection)’. (Details: serial
373 error_code 14 request_code 1 minor_code 0) (Note to programmers:
normally, X errors are reported asynchronously; that is, you will
receive the error a while after causing it. To debug your program,
run it with the –sync command line option to change this behavior.
You can then get a meaningful backtrace from your debugger if you
break on the gdk_x_error() function.)

A quick note on this…I followed the instructions and ran “python Video.py –sync” in command line (I’m on Kubuntu), and I got that message AGAIN.

Here’s the other error – the one that prevents playback at all.

python: ../../src/xcb_io.c:221: poll_for_event: Assertion `(((long)
(event_sequence) – (long) (dpy->request)) <= 0)’ failed. Aborted

These will literally alternate, though not perfectly. I could get three of the first, two of the second, one first, one second, two first, etc. It is always different.

What the devil is going on here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:41:29+00:00Added an answer on May 25, 2026 at 3:41 pm

    You need to synchronise with X server to get window xid.

    Here is how:

        def on_sync_message(bus, message):
            if message.structure is None:
                return False
            if message.structure.get_name() == "prepare-xwindow-id":
                gtk.gdk.threads_enter()
                gtk.gdk.display_get_default().sync()
                win_id = videowidget.window.xid
                imagesink = message.src
                imagesink.set_property("force-aspect-ratio", True)
                imagesink.set_xwindow_id(win_id)
                gtk.gdk.threads_leave()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a project that runs fine on OS4 but we're having problems getting
I have a project that runs on both .NET and .NET CF. But it
I have a django project that runs on a Linux server, and I've been
I have a project that compiles and runs fine on my development machine but
I have a simple Scala project that runs without any problems inside Eclipse, however,
I have a post-build event that runs some commands for a c# project. The
I have a python project that calls a c++ wrapper dll that calls a
I have a project that runs perfect under windows xp. Now I have tried
I have a java project that runs on a webserver. I always hit this
I have created an open source project that runs from Visual Studio. But it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.