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 6821661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:34:16+00:00 2026-05-26T21:34:16+00:00

I have a project with Python, PyGObject (Gtk 3), and GStreamer (0.11) I have

  • 0

I have a project with Python, PyGObject (Gtk 3), and GStreamer (0.11)

I have video in my application, so I’m using a Gtk.Overlay widget so I can put other visual elements over the video background. (I need this, trust me.) (Due to the number of widgets, and the need for specific positioning and overlaying of these widgets, I’m using a Gtk.Fixed container.)

However, in using the Gtk.Overlay object with anything added via “overlay.add_overlay(widget)”, the video is no longer visible at all. I can still hear it, but I cannot see it.

Code below.

from gi.repository import Gtk, Gdk, GdkPixbuf, GdkX11
import pango
import pygst
pygst.require('0.10')
import gst
import Trailcrest
import os, sys
import cairo
from math import pi

class Video:

    def __init__(self):

        def on_message(bus, message): 
            if message.type == gst.MESSAGE_EOS: 
                # End of Stream 
                player.seek(1.0, gst.FORMAT_TIME, gst.SEEK_FLAG_FLUSH, gst.SEEK_TYPE_SET, 5000000000, gst.SEEK_TYPE_NONE, 6000000000)
            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":
                Gdk.threads_enter()
                Gdk.Display.get_default().sync()
                win_id = videowidget.get_property('window').get_xid()
                imagesink = message.src
                imagesink.set_property("force-aspect-ratio", True)
                imagesink.set_xwindow_id(win_id)
                Gdk.threads_leave()

        def click_me(event, data=None):
            player.seek(1.0, gst.FORMAT_TIME, gst.SEEK_FLAG_FLUSH, gst.SEEK_TYPE_SET, 5000000000, gst.SEEK_TYPE_NONE, 6000000000)

        win = Gtk.Window()
        win.set_resizable(False)
        win.set_decorated(False)
        win.set_position(Gtk.WindowPosition.CENTER)

        overlay = Gtk.Overlay()
        win.add(overlay)
        overlay.show()

        videowidget = Gtk.DrawingArea()
        overlay.add(videowidget)
        videowidget.set_halign (Gtk.Align.START)
        videowidget.set_valign (Gtk.Align.START)
        videowidget.set_size_request(640, 480)
        videowidget.show()

        fixed = Gtk.Fixed()
        overlay.add_overlay(fixed)
        fixed.show()

        pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size("IMG/IMG-MPG-LOGO.png", 250, 50)
        imgMPL = Gtk.Image()
        imgMPL.set_from_pixbuf(pixbuf)
        eb_imgMPL = Gtk.EventBox()
        eb_imgMPL.set_visible_window(False)
        eb_imgMPL.add(imgMPL)
        fixed.put(eb_imgMPL, 10, 10)
        imgMPL.show()
        eb_imgMPL.show()

        win.show_all()

        # 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/BGA-HABT-001.ogv")
        player.set_state(gst.STATE_PLAYING)


if __name__ == "__main__":
    Gdk.threads_enter()
    Video()
    Gtk.main()

How do I fix this little issue?

  • 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-26T21:34:17+00:00Added an answer on May 26, 2026 at 9:34 pm

    Answer derived from GNOME Bugzilla Bug 663589, Comments 1-3.

    It is vital to set the valign and halign of any object added via “add_overlay”.

    Therefore, the revised code for declaring and adding the Gtk.Fixed object is as below.

    fixed = Gtk.Fixed()
    
    #The following two lines were added.
    fixed.set_halign(Gtk.Align.START)
    fixed.set_valign(Gtk.Align.START)
    
    overlay.add_overlay(fixed)
    fixed.show()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Python project, which can be installed using Pip. Along with installing
We have a python project that we want to start testing using buildbot. Its
I'm using SQLalchemy for a Python project, and I want to have a tidy
I have a small project I am doing in Python using web.py. It's a
I have a project using python and i want to convert the php to
I have a project built in Python 2.7, using SQLite3 as the database. I
I'm working on a project using Python and pyGTK. I have a window whose
I'have a python project and I decide today put it on github. I'm newbie
I have successfully converted my python project to a service. When using the usual
I have created a textarea in my python project using Pythoncard The problem is,

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.