Re: [pygtk] get the XID from gtk.Drawingarea
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] gtkmain running
is there a way to test wehter or not gtkmain is running from within python? i am in the situation where my program initiates two threads, oe which starts gtkmain, the other may create a dialogue early on - possibly before gtkmain is fuly up and running Keir Lawson -- ___ 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] dsextra.py installed with PyGTK 2.4.1 binaries (windows)
Hi, I am trying to build and install PyGTKGLext for Windows with Python 2.4 and PyGTK 2.4.1. The build process was successful but the install one failed. I get the following error : C:\msys\1.0\home\Stephane\pygtkglext-1.0.1setup.py build --compiler=mingw32 install running build running build_py running build_ext using MinGW GCC version 3.4.2 with -mms-bitfields option running install running install_lib Traceback (most recent call last): File C:\msys\1.0\home\Stephane\pygtkglext-1.0.1\setup.py, line 158, in ? cmdclass={'install_lib': PyGtkGLExtInstallLib, File C:\Python24\lib\distutils\core.py, line 149, in setup dist.run_commands() File C:\Python24\lib\distutils\dist.py, line 946, in run_commands self.run_command(cmd) File C:\Python24\lib\distutils\dist.py, line 966, in run_command cmd_obj.run() File C:\Python24\lib\distutils\command\install.py, line 505, in run self.run_command(cmd_name) File C:\Python24\lib\distutils\cmd.py, line 333, in run_command self.distribution.run_command(command) File C:\Python24\lib\distutils\dist.py, line 966, in run_command cmd_obj.run() File C:\msys\1.0\home\Stephane\pygtkglext-1.0.1\setup.py, line 61, in run self.add_template_option('VERSION', VERSION) File C:\Python24\lib\distutils\cmd.py, line 112, in __getattr__ raise AttributeError, attr AttributeError: add_template_option After investigating, I remarked that dsextra.py installed in C:\Python24\Lib\site-packages\gtk-2.0 is different than the one provided in the pygtk-2.4.1 source package. Indeed, it contains the definition of InstallData class which is more recent than the 2.4.1 version, according to the pygtk CVS. And the InstallLib class has no add_template_option() method any more (that's why there's an error...). But after looking at this file, I found that it is also different to the next CVS one... So I am completely messed up but I still want to update the setup.py of PyGTKGLext package in order to get a working binary installer for Windows. How shoud I use the new InstallData class ? Which version of dsextra shoud I refer to ? FYI, I used the already-build pkgtk binary installer for windows. Thanks a lot! Stéphane ___ 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] gtkmain running
I think gtk.main_level will give you the information you want. http://www.pygtk.org/pygtk2reference/gtk-functions.html#function-gtk--main-level On a side note, does anyone know of a good way to catch uncaught exceptions with sys.excepthook and gracefully call gtk.main_quit the right number of times to perform a graceful termination? -Chris On Wed, 02 Mar 2005 20:23:50 +, Keir Lawson [EMAIL PROTECTED] wrote: is there a way to test wehter or not gtkmain is running from within python? i am in the situation where my program initiates two threads, oe which starts gtkmain, the other may create a dialogue early on - possibly before gtkmain is fuly up and running Keir Lawson -- ___ 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/ -- Christopher Lambacher [EMAIL PROTECTED] ___ 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/