Hi,
Here is a patch for pygtk that exposes some of the lower-level gdk_window
functionality (creation of a gdk_window, show, hide, destroy) to Python.
The motivation for this was a need to use an INPUT_ONLY GDK window to set
the cursor on the entire surface of a window, and to block mouse and
keyboard interaction with that window during that time (as you would when
the GUI is going to be unresponsive for a while due to some more lengthy
syncronous operation).
This could be used for other things as well, wherever there is a need to
temporarily overlay an existing window with an event-trapping transparent
window.
With this patch, you can now say something like this to set up a watch
cursor on any gtk_window:
gdk_window = my_gtkwindow.get_window()
attribs = { 'wmclass': GDK.INPUT_ONLY,
'window_type': GDK.WINDOW_CHILD,
'event_mask': 0,
'x': 0,
'y': 0,
'width': gtk.screen_width(),
'height': gtk.screen_height() }
cursor_win = gtk.gdk_window_new(gdk_window, attribs)
gdk_cursor = gtk.cursor_new(GDK.WATCH)
cursor_win.set_cursor(gdk_cursor)
cursor_win._show()
To set things back to normal you do this:
cursor_win._hide()
To show the watch again later:
cursor_win._show()
And when you're done with the cursor-setting window you say:
cursor_win.destroy()
cursor_win = None
This patch replaces the one that was sent by me to this list on Fri, 20
Oct 2000 20:28:38 -0400 (EDT). It is a cdiff based on a somewhat modified
pygtk 0.6.5, so may not apply automatically. But hopefully it's not too
hard to figure out, since it's just a set of added functions in several
files. The 'WINGIDE_EXTENSION' ifdefs and comments can of course be
removed.
Please let me know if you have any questions or run into any problems
with this.
I hope that it's something that can be considered for a future version
of pygtk.
Thanks,
- Stephan
Archaeopteryx Software, Inc.Wing IDE for Python
www.archaeopteryx.com Take Flight!
Index: GDK.py
===
RCS file: /home/cvs/src/ide/external/pygtk-0.6.5-wing/GDK.py,v
retrieving revision 1.1
diff -c -r1.1 GDK.py
*** GDK.py 2000/03/13 18:45:37 1.1
--- GDK.py 2000/10/27 15:04:30
***
*** 294,299
--- 294,313
XTERM = 152
CURSOR_IS_PIXMAP = -1
+ # WINGIDE_EXTENSIONS
+ # GdkWindowClass's
+ INPUT_OUTPUT = 0
+ INPUT_ONLY = 1
+
+ # GdkWindowType's
+ WINDOW_ROOT = 0
+ WINDOW_TOPLEVEL = 1
+ WINDOW_CHILD = 2
+ WINDOW_DIALOG = 3
+ WINDOW_TEMP = 4
+ WINDOW_PIXMAP = 5
+ WINDOW_FOREIGN = 6
+ # END WINGIDE_EXTENSIONS
# these are the Key Symbols for GDK
# they were created with sed -n 's/#define GDK)\([^ ]*\)/\1 =/p' gdkkeysyms.h
Index: gtk.py
===
RCS file: /home/cvs/src/ide/external/pygtk-0.6.5-wing/gtk.py,v
retrieving revision 1.8
diff -c -r1.8 gtk.py
*** gtk.py 2000/09/25 19:47:24 1.8
--- gtk.py 2000/10/27 15:04:41
***
*** 2738,2743
--- 2738,2769
keyval_to_upper = _gtk.gdk_keyval_to_upper
keyval_to_lower = _gtk.gdk_keyval_to_lower
+ # WINGIDE_EXTENSIONS
+ # Low-level function to create new gdk window
+ def gdk_window_new(parent, attribs):
+ """ Creates a new gdk window which must be destroyed with an
+ explicit call to the _destroy() method. parent is the new
+ window's parent PyGdkWindow or None if the window should be a
+ child of the root window. attribs must be a dictionary of
+ attribute values for the window; the following attribs must
+ be specified:
+ window_type -- GDK.WINDOW_TOPLEVEL, GDK.WINDOW_CHILD
+GDK.WINDOW_DIALOG, GDK.WINDOW_TEMP
+GDK.WINDOW_PIXMAP, or GDK.WINDOW_FOREIGN
+ event_mask -- the events to get
+ width -- width of window
+ height -- height of window
+ The following attributes are optional:
+ wmclass -- GDK.INPUT_OUTPUT or GDK.INPUT_ONLY
+ x -- x offset from parent
+ y -- y offset from parent
+ colormap -- PyGdkColormap to use to interpret colors
+ override_redirect -- see gdk / X documentation
+ """
+
+ return _gtk.gdk_window_new(parent, attribs)
+ # END WINGIDE_EXTENSIONS
+
# screen size
def screen_width():
return _gtk.gdk_screen_width()
Index: gtkmodule.c
===
RCS file: /home/cvs/src/ide/external/pygtk-0.6.5-wing/gtkmodule.c,v
retrieving revision 1.10
diff -c -r1.10 gtkmodule.c
*** gtkmodule.c 2000/09/28 22:49:52 1.10
--- gtkmodule.c 2000/10/27 15:05:30
***
*** 1665,1670
---