Re: [pygtk] get the XID from gtk.Drawingarea

2005-03-02 Thread Rafael Villar Burke
Holger Reinmann wrote:
Hello,
 

When I try to get the XID from the gtk.drawingarea with da.window.xid I
get an Errormsg None Type Object has no attribute XID
greetings holger
Sorry, the example showed the XID for the window were the button is 
being painted, and that is its parent's window (the main window on this 
occasion), as gtk.Buttons don't own an X window for themselves.

With some changes the example at the end should work now as expected.
Anyway, remind that the window for which you want to know the XID must 
have been realized (if it's exposed you know that happens for sure). If 
you want to do this in a class that inherits from gtk.DrawingArea that 
means you should get the XID inside an on_expose_event(...) callback 
method connected to the configure event for the gtk.DrawingArea. 
Possibly you can do that too earlier (not sure about this) inside a 
similar on_realize (for the realize event) chaining up the event before 
getting the window, just for the case it runs before the parent class' 
method runs.

Fleshed out, this last idea would be coded as something like this:
example 1
Print a widget's XID when the widget is a class inherited from 
another gtk widget.

import pygtk
pygtk.require('2.0')
import gtk
def show_widget_xid_datum(sender, widget):
  sender.set_label(X window ID: %s % (widget.the_xid_you_want,))
class GraphArea(gtk.DrawingArea):
   def __init__(self):
  gtk.DrawingArea.__init__(self)
  self.connect('expose-event', self.on_expose_event)
   def on_expose_event(self, widget, event):
  self.the_xid_you_want = widget.window.xid
  return False
window = gtk.Window()
vbox = gtk.VBox()
ga = GraphArea()
ga.set_size_request(200,100)
button = gtk.Button(Press me)
button.connect(clicked, show_widget_xid_datum, ga)
vbox.pack_start(button)
vbox.pack_start(ga)
window.add(vbox)
window.set_title(GraphArea XID example)
window.connect(destroy, gtk.mainquit)
window.show_all()
gtk.main()
\example 1
And here is the first example, corrected:
example 2
Print a widget's XID
import pygtk
pygtk.require('2.0')
import gtk
def show_widget_xid(sender, widget):
  sender.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_widget_xid, da)
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/


[pygtk] get the XID from gtk.Drawingarea

2005-03-01 Thread Holger Reinmann
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.

Thanks 
greetings 
Holger Reinmann



-- 
Lassen Sie Ihren Gedanken freien Lauf... z.B. per FreeSMS
GMX bietet bis zu 100 FreeSMS/Monat: http://www.gmx.net/de/go/mail
___
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/


Re: [pygtk] get the XID from gtk.Drawingarea

2005-03-01 Thread Rafael Villar Burke
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/