True standard Windows app in Python?

Dave Brueck dave at pythonapocrypha.com
Mon Dec 29 20:15:55 EST 2003


Alan wrote:
> > > Well for example writing a fully windows compliant screne saver
> > > is impossible using Python
> >
> > You may find this link interesting then. :)
> >
> > http://homepage.hispeed.ch/py430/python/index.html
>
> Actually that's pretty darned impressive but from scanning the
> code its not fully windows compliant because it doesn't include
> the code to cover all the standard corner mouse clicks or
> keyboard shortcuts, neither is it plumbed into the GINA(?)
> security module so far as I can tell to enable password control.
> But OTOH that should be possible...

Yes - it's most definitely possible. I don't blame the author of that code for
not doing it of course.

> > > Gives you access to the types but not the low level win32 APIs.
> >
> > Are you sure you know what ctypes does? What "low level win32 APIs" are you
> > referring to?
>
> The win32 API calls that sit below MFC.

These are very easily accessible via ctypes (I don't use MFC at all).

> In particular the device
> IO ones for talking to PCI cards and the like.

If they are standard Win32 APIs, then they are accessible. If they aren't
standard Win32 APIs, then they don't fit inside the definition of a "true
standard Windows app" anyway.

> And you are right I didn't realize all that ctypes could do, I'd
> only seen it as a wrapper around the C typesystem - as per the
> name! I didn't know, till now, that you could access DLL
> functions, so in principle(albeit painfully) you should be able
> to access all of the win32 API.

Not too painfully, actually. The biggest hurdle is creating the Python version
of the structures that get passed around, but that's a one-time hit - after
that it's straightforward.

> So yes, you could use Python to write a full windows compliant
> program, OTOH I'm still not sure that I'd want to write C in
> Python! :-)

Well, I guess that depends. I've been using ctypes almost daily for a year or
so and now I find it annoying to do Win32 programming in C! It's not that
you're writing C in Python as Win32 programming mostly populating structures,
calling functions, and checking error codes - very little of it is actually
language-specific or "normal" C code; rather, it's tedious work in all
languages, so in Python it's nice because you cut out the tediousness of C and
have just the tediousness of Win32 left. ;-)

-Dave






More information about the Python-list mailing list