[python-win32] Displaying contents of a file using PyWin
Gabriel Genellina
gagsl-p32 at yahoo.com.ar
Fri Dec 22 07:11:08 CET 2006
At Friday 22/12/2006 00:28, Mark Hammond wrote:
> >import win32ui
> > >from pywin.mfc import docview
> > >
> > >t = docview.DocTemplate()
> > >t.OpenDocumentFile("d:/temp/music.log", True)
> > >
> > >This caused windows to close PythonWin.
> >
> > This appears to be a problem with pywin32.
> > Using release 209 for Python 2.4 I get an Access Violation.
>
>It was attempting to set a Python error without the GIL held. I've fixed
>that - it now results in:
>
>win32ui: PyCDocument::OnOpenDocument handler does not exist.
> >>>
Oh, thanks!
>Using:
>
> >>> t.OpenDocumentFile(None)
>
>Opens a document - I'm afraid I can't recall the MFC semantics here at the
>moment.
I think one should inherit from docview.Document and write the
OnOpenDocument handle, but I'm not sure either. I hope the OP has
enough info to continue from here.
> > Also I've noticed that this idiom:
> >
> > try:
> > win32ui.GetApp().RemoveDocTemplate(template)
> > except NameError:
> > # haven't run this before - that's ok
> > pass
> >
> > doesn't work anymore because RemoveDocTemplate raises a different
> > exception now.
>
>I can't recall any change I made that would account for that. I'm assuming
>that the NameError comes from 'template' which is yet to be assigned - but
>in that case RemoveDocTemplate should not be called as the NameError happens
>before. I don't recall (and grep doesn't show) that pythonwin ever raises
>this exception.
It is used in 4 scripts inside pythonwin\pywin\framework.
And can be found on your own book, chapter 20...
--
Gabriel Genellina
Softlab SRL
__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas
More information about the Python-win32
mailing list