Trying the impossible?
sebastian at wangnick.de
Sun Sep 22 14:08:55 CEST 2002
yesterday I recompiled Tcl/Tk (8.4.0) and pythoncore/python/_tkinter (2.2.1)
in debug mode with VC 6.0. Now, when trying my script, I'm getting the
PyThreadState_Get: no current thread
This is happening when NTDLL tries to call my_wndproc via calldll.
It seems to me that the following is happening: Within Tkapp_MainLoop,
before calling Tcl_DoOneEvent, the code saves the current thread state
within tcl_tstate and then releases the interpreter_lock, setting the
_PyThreadState_current to NULL. Whenever Tcl calls back to Python, the
ENTER_PYTHON macro re-acquires the interpreter_lock and restores the thread
state. However, in my script this is not performed, as it is Windows calling
my script, and calldll doesn't know that it has to reacquire the interpreter
lock, nor where to find the thread state!
I undef'd WITH_THREAD in pyConfig.h and recompiled, and then my script
I'm uncertain how to best make calldll thread-safe under these
circumstances. Maybe the author can help?
"Sebastian Wangnick" <sebastian.wangnick at eurocontrol.int> wrote in message
news:30292041.0209210032.6e07d9f3 at posting.google.com...
> Dear all,
> I'm trying to overload, using dynwin/calldll under Windows, the
> Tkinter drawing routines to perform some additional drawing on top of
> My first attempt was to bind to "<Expose>", but this binding seemingly
> is triggered before Tk performs its drawing, so my stuff was erased by
> Tk :(
> Now I'm trying to overload the WindowProc itself. To test the
> mechanism, I started by simply passing everything on to
> from Tkinter import *
> import dynwin
> import dynwin.gencb
> import dynwin.windll
> import dynwin.winwin
> user32 = dynwin.windll.module ('user32')
> def my_winproc (hwnd, message, wparam, lparam):
> return user32.CallWindowProc (tk_winproc,
> hwnd, message, wparam, lparam)
> my_winproc_cb = dynwin.gencb.generated_callback ('llll', my_winproc)
> def map (event):
> global tk_winproc
> hwnd = frame.winfo_id()
> tk_winproc = user32.GetWindowLong (hwnd,
> user32.SetWindowLong (hwnd, dynwin.winwin.GWL_WNDPROC,
> root = Tk()
> frame = Frame(root,width=100,height=100)
> However, when starting this it crashes with 'The instruction at
> "0x1e0381fa" referenced memory at "0x00000008". The memory could not
> be "read".'
> Any idea what I'm doing wrong? I'm using XP, btw.
More information about the Python-list