Holger Reinmann wrote:

Hello Folks,

I want to write a small mplayer GUI in pygtk.
The Gui contain a gtk.Drawingarea in that mplayer
should display the video.

For this I need the XID from the Drawingarea. How do i get this? I have read the tutorial and the reference
very often but it don't work.


I also read the mailing list. And found that other people has similar problems with version 1.99.X. But I'm using pygtk 2.4.1 and python 2.3 from debian unstable.


You have to get the gtk.gdk.Window of your gtk.DrawingArea and read its
"xid" attribute (provided by the gtk.gdk.Drawable ancestor:
http://pygtk.org/pygtk2reference/class-gdkdrawable.html ). If you have
problems getting the window that is probably due to it not being
realized yet. You must get the window after it exists... until then the
DrawingArea is created but not its associated gtk.gdk.Window so you
properly get None.

This dummy example works here:

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

def show_xid(widget):
   widget.set_label("X window ID: %s" % (widget.window.xid,))

window = gtk.Window()
vbox = gtk.VBox()
da = gtk.DrawingArea()
da.set_size_request(200,100)
button = gtk.Button("Press me")
button.connect("clicked", show_xid)
vbox.pack_start(button)
vbox.pack_start(da)
window.add(vbox)
window.set_title("DrawingArea example")
window.connect("destroy", gtk.mainquit)

window.show_all()
gtk.main()

Take care,

Pachi

_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to