Tkinter and C extensions

Bernhard Herzog herzog at online.de
Wed Apr 5 18:49:16 EDT 2000


Andrew MacIntyre <andymac at bullseye.apana.org.au> writes:

[...]
> My research has turned up ways of determining these via Tk's API
> (Tk_Display(), Tk_Window() in tk.h) provided I can extract the tkwin
> handle from Tkinter's canvas widget - something I've yet to figure out how
> to do from within a C extension.
> 
> I'm wondering whether its possible to get at this information via Tkinter,
> which would simplify the interactions between the various components.

Tkinter widgets have a tk attribute which is basically a tcl
interpreter. It's interpaddr() method returns the TclInterp* pointer as
a python int object. Just pass that and the name of the widget to a
C-extension function and the rest follows from that...

> Any hints on additional sources of enlightment, such as other modules
> which have similarities, would be appreciated.

Sketch's paxmodule does something similar. Sketch uses it to implement
widgets in Python, which allow you to handle expose events yourself and
use Xlib functions to draw the widgets.

-- 
Bernhard Herzog   | Sketch, a drawing program for Unix
herzog at online.de  | http://sketch.sourceforge.net/



More information about the Python-list mailing list