"Greg Ewing" <greg.ew...@canterbury.ac.nz> wrote in message 
news:4cbfa5e9.7090...@canterbury.ac.nz...
> On 21/10/10 14:02, Roger Upole wrote:
>
>> The problem stems from these 2 lines in ScrollableViews.py:
>>
>> rev = ui.CreateRichEditView()
>> win_dummy_doc = rev.GetDocument()
>>
>> The win32ui framework really should not allow a view to be created
>> without a valid document.
>
> Actually, the problem is that it *won't* allow a view to be
> created without a document, even though it should. If I remember
> correctly, at the MFC level, the constructor for the view object
> I'm using doesn't even take a Document as an argument -- you set
> it later if you want one. Win32ui goes out of its way to accept
> one at construction time.
>
> This wouldn't be such a serious problem, except that win32ui
> doesn't seem to provide any way of creating a Document without
> a resource -- hence the above kludge.

You instantiate the MFC view object without a document, but in order
to actually create a window and do anything useful with it, it needs
a valid document.  For some reason, the win32ui framework
chooses to accept a document when the view is initially created
instead of when its window is created.  (That's where MFC
accepts the associated document object.)

I have yet to be able to determine where the dummy document is
actually coming from in build 212.  When I try to run it in a
debug build, so many asserts are triggered that it would take
forever to step thru it.

>> The PyGUI framework can probably create a valid MFC document to use
>> as a dummy with a little work.
>> Something like:
>> dt=win32ui.CreateDocTemplate(win32ui.IDR_PYTHONTYPE)
>> win_dummy_doc=dt.DoCreateDoc()
>
> That may work if you run the program using the pythonwin
> executable, which contains the referenced resource. But I want
> pygui programs to be runnable using the standard Python
> interpreter, which means I can't rely on resources at all.

The resource is actually in win32ui.pyd, rather than in Pythonwin
itself.  I've just verified that this method works from plain python.exe.
The scrollable view test runs with this change.

       Roger



_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to