Rafael Villar Burke
Wed, 02 Mar 2005 02:57:56 -0800
Holger Reinmann wrote:
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.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
With some changes the example at the end should work now as expected.
Fleshed out, this last idea would be coded as something like this:
import pygtk
pygtk.require('2.0')
import gtkdef 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 Falsewindow = 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 gtkdef 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/