Windows Console Driver

Updated 2007-05-09: A new build for 2.5 is available, which fixes the event handler crashes under 2.5. Thanks to “H. Stelling”, “Michael K”, and the signature “K” for feedback. /F

Updated Jan 20, 2002 | Fredrik Lundh

The Console module is a simple console driver for Windows 9X/NT/2K/XP. It also provides Python command line history and editing facilities for Windows platforms.

Documentation #

The Console Module

Download #

The latest version is available from the effbot.org downloads page.

 

Comment:

I experienced random crashes on WinXP/Py2.5 when using the publicly available releases. I think there is an error in the *_dealloc functions: //PyMem_DEL(self); should be PyObject_Del(self);

Posted by K (2007-05-05)

Comment:

In addition, you could make Console non-blocking by using the relevant macros, like: // console_get Py_BEGIN_ALLOW_THREADS status = ReadConsoleInput(self->in, &event, 1, &count); Py_END_ALLOW_THREADS // console_getchar PyObject *result = NULL; Py_BEGIN_ALLOW_THREADS for (;;) { status = ReadConsoleInput(self->in, &event, 1, &count); if (status && count == 1 && event.EventType == KEY_EVENT && event.Event.KeyEvent.bKeyDown) { char* sym = keysym(event.Event.KeyEvent.wVirtualKeyCode); if (sym && sym[0]) { result = Py_BuildValue("s", sym); break; } else { result = Py_BuildValue( "c", event.Event.KeyEvent.uChar.AsciiChar ); break; } } } Py_END_ALLOW_THREADS return result; I hope the code sections will come out allright :)

Posted by K (2007-05-05)

A Django site. this page was rendered by a django application in 0.04s 2008-05-10 22:37:52.914309. hosted by webfaction.