[Pythonwin] Help needed creating a Window

Dave Kirby dkirby at bigfoot.com
Tue May 25 06:06:43 EDT 1999


I am writing an app in pythonwin that will sit in the background with
only an icon in the system tray. After some trial and error I have
managed to create the icon, but I need to give it a handle to a window
that will be used to process its messages.

I have tried to create a window with the following (and many
variations on the theme):

>>> win = win32ui.CreateWnd()
>>> win.CreateWindow( None, "", win32con.WS_CHILD, (0,0, 10,10), None, 0 )
Traceback (innermost last):
  File "<interactive input>", line 0, in ?
SystemError: NULL result without error in call_object

What am I doing wrong here?  Once I have created the window, how do I
get at its HWND? As far as I can tell there is no way to access it
from a PyCWnd. Alternatively does the win32ui.Shell_NotifyIcon
function accept a PyCWnd? (From a quick experiment it doesnt seem
too).

As an alternative I tried the win32gui.CreateWindow function which
does return a handle, but I got the following:

>>> h = win32gui.CreateWindow( 0, "wibble", 0, 0,0, 10,10, 0, None)
Traceback (innermost last):
  File "<interactive input>", line 1, in ?
TypeError: CreateWindow requires exactly 11 arguments; 9 given

The documentation only specifies 9 arguments, so I am stumped. I also
assume that if I got a HWND this way I would not be able to specify
python message handlers for the window, which would defeat the whole
point. 

Any help would be greatly appreciated, even if only to tell me that
what I am doing is not possible in pythonwin.

	Dave Kirby




More information about the Python-list mailing list