Pythonwin - advise sought

Mark Hammond MHammond at skippinet.com.au
Thu Jun 10 18:26:03 EDT 1999


Colin J. Williams wrote in message <375FA468.98976DDF at connection.com>...
>I am looking at Pythonwin as an alternative to Tk and would appreciate
advice on
>the following three questions.
>
>The Pythonwin documentation points to MFC documents as a source of
information.
>The MSDN site has:
>
>http://msdn.microsoft.com/library/devprods/vs6/vc++/vcmfc/_mfc_about_the_mi
crosoft_foundation_classes.htm'''
>
>Q1:  Are there better sources which can be recommended?

Not buy me.  Ive been doing MFC for years now and never owned a book on it
:-(

>The code fragment below:
>
>       code1= "win32ui.CreateFileDialog(1)"
>       fd= eval(code)
>       print(repr(fd))
Or:
  print repr(win32ui.CreateFileDialog(1)) :-)

>     object 'PyCFileDialog' - assoc is 007CC240, vf=False,
>     notify=0,ch/u=0/0, mh=0,kh=0

These are really for debugging:
assoc is: The address of the MFC object wrapped (ie, the CFileDialog)
vf=false: Is there a .py class associated with this C+ object?
notify=0: How many HookNotify() calls have been made on the object
ch/i=0/0: Can't remember - use the source :-)
mh=0: How many HookMessage calls.
kh=0: How many keyboard handlers.

>Q3.  Is there some way that one can test that fd is an instance of some
class,
>any class?

FD is not a class, it is a type.  There are no good examples for a file
dialog, but consider:

>>> ps=win32ui.CreatePropertySheet("Test")
>>> ps
object 'PyCPropertySheet' - assoc is 01102980, vf=False, notify=0,ch/u=0/0,
mh=0, kh=0
>>>

Same as your example.  Now lets create a property sheet using a Python
class:

>>> ps=pywin.mfc.dialog.PropertySheet("Test")
>>> ps
<pywin.mfc.dialog.PropertySheet instance at 1103080>

Now it is a Python class.  We can get the win32ui type object by looking at
_obj_ - ie:
>>> ps._obj_
object 'PyCPropertySheet' - assoc is 01104F10, vf=True, notify=0,ch/u=0/0,
mh=1, kh=0
>>>

Note in this example we have "mh=1" indicating that the
pywin.dialog.PropertySheet class hooked a single windows message.

Hope this helps...

Mark.






More information about the Python-list mailing list