wierd win32all gui problem (w/56lines of code)

Jeffrey Drake jpt.d at home.com
Thu Oct 25 01:58:05 EDT 2001


Using ActivePython 2.1 and win32all I have written a simple app that creates
a window and exits when closed. However the python interpreter is still
running. It hangs a command prompt under win2k until I physically kill the
python process. I would appreciate any help possible.

Regards,
jptd
(feel free to email me)

-- code -- (functions separated by ---------- for loss of indentation)

from win32api import *
from win32gui import *
from win32event import *
import win32con

class RegisterError:
 pass

class CreationError:
 pass

def InitApplication():
 global hinst

 wc = WNDCLASS()

 wc.hIcon =  LoadIcon(0, win32con.IDI_APPLICATION)
 wc.hCursor = LoadCursor( 0, win32con.IDC_ARROW )
 wc.hbrBackground = win32con.COLOR_WINDOW
 wc.lpszClassName = "MyWin"
 wc.lpfnWndProc = WndProc
 hinst = wc.hInstance = GetModuleHandle(None)

 if not RegisterClass(wc):
  raise RegisterError

def InitInstance():
 global hWnd

 hWnd = CreateWindowEx(
  win32con.WS_EX_APPWINDOW,
  "MyWin",
  "Test Application",
  win32con.WS_OVERLAPPED | win32con.WS_SYSMENU,
  win32con.CW_USEDEFAULT, 0,
  win32con.CW_USEDEFAULT, 0,
  0, 0, hinst, None)

 if not hWnd:
  raise CreationError

 ShowWindow(hWnd, win32con.SW_SHOWDEFAULT)

 UpdateWindow(hWnd)

 return
-----------
def WndProc(hWnd, uMsg, wParam, lParam):
 if uMsg == win32con.WM_DESTROY:
  PostQuitMessage(0)

 return DefWindowProc(hWnd, uMsg, wParam, lParam)
---------

InitApplication()
InitInstance()
PumpMessages()





More information about the Python-list mailing list