sdk32 - Partial Python wrap of the Win32 Platform SDK
Introduction
sdk32 is a thin Python wrapper around some of the Win32 Platform SDK. The following program is the Hello World application.
from sdk32 import * ps = PAINTSTRUCT() rect = RECT() def wnd_proc(wnd, msg, wparam, lparam): global ps, rect if msg == WM_PAINT: dc = BeginPaint(wnd, ps) GetClientRect(wnd, rect) DrawText(dc, 'Hello Windows!', -1, rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER) EndPaint(wnd, ps) return 0 elif msg == WM_DESTROY: PostQuitMessage(0) return 0 return DefWindowProc(wnd, msg, wparam, lparam) def winmain(inst, prev_inst, cmd_line, cmd_show): app_name = 'HelloWin' wc = WNDCLASSEX() wc.style = CS_HREDRAW | CS_VREDRAW wc.wnd_proc = wnd_proc wc.inst = inst wc.cursor = LoadCursor(0, IDC_ARROW) wc.background = GetStockObject(WHITE_BRUSH) wc.name = app_name RegisterClassEx(wc) wnd = CreateWindow(app_name, 'The Hello Program', WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, inst, 0) ShowWindow(wnd, cmd_show) UpdateWindow(wnd) msg = MSG() while 1: if not GetMessage(msg, 0, 0, 0): break TranslateMessage(msg) DispatchMessage(msg) return msg.wparam if __name__ == '__main__': winmain(GetModuleHandle(None), 0, '', SW_SHOWNORMAL)