GUIs - A Modest Proposal

lkcl luke.leighton at gmail.com
Sat Jun 12 11:34:48 EDT 2010


On Jun 9, 5:16 pm, Ethan Furman <et... at stoneleaf.us> wrote:
> Gregory Ewing wrote:
> > Kevin Walzer wrote:
> >> PyGUI ... certainly is *not* a lightweight GUI toolkit that could
> >> easily be incorporated into the Python core library--it instead has
> >> rather complex dependencies on both other GUI toolkits and Python
> >> wrappers of those toolkits.
>
> > I don't see how the dependencies could be regarded as "complex".
> > There's more or less only one on each platform, and they're
> > pretty standard accessories for the platform concerned. You could
> > say there are two on Linux if you count gtk itself, but you almost
> > certainly already have it these days if you're running any
> > kind of desktop at all.
>
> *Alert*  Potentially dumb question following:  On the MS Windows
> platform, Gtk is not required, just win32?

 by using python-comtypes and python-ctypes, you can pretty much
control absolutely anything that's installed, and access just about
anything: any win32 dll, any function.  some of the function
parameters you might have to guess, but it's doable.

 in this way you can actually access the win32 GDI (graphics driver
interface) which is a serrriously low-level GUI toolkit built-in to
the win32 API, and can implement much higher-level APIs on top of it.
GDI is somewhat at the level of the X11 protocol.

 as it's so low-level, the number of applications which actually do
this is _extremely_ small.  the only reason i got involved at all was
to do the aaaabsolute minimum amount of work required to embed _one_
single object instance into a GDI window, taking up the entire width
and height: an IWebBrowser2 OCX control, lifted straight out of
MSHTML.DLL.

 you can look at what i did, here:
http://pyjamas.git.sourceforge.net/git/gitweb.cgi?p=pyjamas/pyjamas;a=tree;f=pyjd;hb=master

 see windows.py and pyjd.py.  windows.py is lifted straight out of a
library by henk punkt; pyjd.py is a mish-mash amalgam of various bits
of code i found by googling for 3 weeks solid on variations of "python
MSHTML IWebBrowser2" and so on.  much of the work that i found i had
to go back _years_, to older versions of python and older python
libraries that have long since been retired because nobody bothered
with the techniques that were offered.

 so, yah. thanks to henk punkt's little windows.py module, it's
possible to "appear" to have direct access to win32 functions such as
"CreateWindowEx", and thanks to python-comtypes it's possible to get
access to the COM interface of DLLs and then you're off (in this case,
with the fairies).

 l.



More information about the Python-list mailing list