I am trying to use IDLE as a front-end to an embedded Python
interpreter in a Windows application that is based on normal Win32
event loops. However, when Tkinter enters its mainloop it predictably
enough locks up the parent Windows application, since it is not run in
a separate thread. I tried to use Python's threading facilities to
start IDLE in a separate thread in Python, which seems to work
partially. The Python thread is fired up and politely yields control to
the Win32 application. Unfortunately the Windows application never
yields it back. What do I have to do to get the threads to coexist and
yield control to each other?

Below is the C++ code for the Win32-application's mainloop:

while (PeekMessage(&msg, NULL, 0, 0, PM_NOYIELD | PM_REMOVE)) {

I've tried removing the PM_NOYIELD option, which seems to have no
effect. I've also tried adding a call to the Win32 API function Sleep
(0) after the call to DispatchMessage, which likewise has no noticeable
effect. Is the Python thread of lower priority than the Win32

This is the Python code that starts up the thread (the idle() function
is called):

import threading

def run():
import PyShell
PyShell.main() # Starts IDLE and enters the Tkinter mainloop

def idle():
idlethread = Thread(target = run)

I would be grateful for any pointers on how to get around this problem.

Ludvig Svenonius
Excosoft AB
ludvig at excosoft.se

Sent via Deja.com http://www.deja.com/
Before you buy.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
postedSep 5, '00 at 2:55p
activeSep 5, '00 at 2:55p

1 user in discussion

Lss: 1 post



site design / logo © 2022 Grokbase