0

I have a project built in Python, PyGTK 2.24, and PyGST (GStreamer). I have my video working perfectly in a gtk.DrawingArea object.

However, I need to display other GUI elements OVER this video while it is playing. (Please don't ask why, just trust me.) Right now, they all appear to be behind. In the code, the video objects (and gtk.DrawingArea) are declared and put into the gtk.Fixed FIRST, following by everything else.

So, how do I do this? Do I need to change what object GStreamer is playing on? I know it is possible...I've seen GStreamer programs that have things like buttons and labels sitting on top of the video.

Thanks in advance!

2

2 Answers 2

2

You can do this in GTK 3.2 and above using GtkOverlay.

If you can't upgrade, then here is a summary of the old-fashioned way: connect to the expose-event signal of the DrawingArea, and paint the information on yourself using Cairo. When the information changes, trigger a redraw of the drawing area using widget.queue_draw(). Make sure your handler runs after the handler that draws the actual video onto the drawing area. This will work for labels and non-interactive GUI elements.

If you want an actual functioning GUI element to hover above your video, that's rather more complicated and I don't know how to do it. I don't think Fixed guarantees any z-order. I suspect that your buttons and whatnot are being overpainted by the video being drawn onto the drawing area, so maybe triggering a redraw of those in your expose-event handler will work.

8
  • That is not available in PyGTK, according to the documentation. I need something that matches my stated project specifications, please. Oct 14, 2011 at 17:49
  • @JasonMc92: Ok, but you didn't specify that upgrading was impossible. Keep in mind that the programs in which you saw it was possible may use GTK 3 themselves.
    – ptomato
    Oct 17, 2011 at 9:06
  • @downvoter: not everybody who comes to this question from Google is going to have the same project specifications as Jason.
    – ptomato
    Oct 17, 2011 at 9:07
  • I originally downvoted because the answer was not useful at all (which is verbatum what a downvote means. Now that you extended it to something which matches my project specs (and additionally, perhaps other people's), I can upvote. Anyway, I don't think it is possible to "upgrade" anything here. The latest version of PyGTK is 2.24, and I must use PyGTK, since I need the Python bindings. Oct 17, 2011 at 15:30
  • @JasonMc92, PyGTK has been superseded by PyGObject, which covers 3.0 and up. PyGObject is the new Python bindings.
    – ptomato
    Oct 17, 2011 at 19:13
2

Probably of no use to the OP, but I searched for a long time looking for a way to place widgets over the top of a gtk.gdk.Drawable element (which could be a statically drawn image, animation or video) before I finally figured out how to do this in pygtk2.

Here's a link to what I came up with: http://bazaar.launchpad.net/~damien-moore/picty/trunk/view/642/modules/picty/overlay_widgets.py

This includes 3 custom classes:

ProportionalLayout: an implementation of a custom gtk.Container that lets the user position child widgets using proportions.

DrawableOverlay: an EventBox that emits a 'draw' event for the user to connect to and do drawing on, and displays a ProportionalLayout on top.

DrawableOverlayHover: a DrawableOverlayHover that only shows the widgets if the pointer gets "close" to them.

The sample main program illustrates how to use them. The code should be reasonably straightforward to adapt to a video application.

1
  • While I've switched languages altogether, I'm sure this'll be a useful solution to someone else. Thanks for the research! May 24, 2013 at 2:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.