Defining a Simple Framework
Our first step is to develop a simple framework with placeholders for the major objects.
We define three objects: a
ScribbleTemplate, a
ScribbleDocument, and a
ScribbleView. These objects derive their
implementation from objects in the
pywin.mfc.docview
module. The
ScribbleTemplate object remains empty in this
implementation. The ScribbleDocument object has a
single method,
OnNew-Document()
, which is called as a document object is
initialized; the implementation defines an empty list of strokes. The
view object is based on a
PyCScrollView
(i.e., an MFC
CScrollView) and defines a single method
OnInitialUpdate()
. As the name implies, this method is
called the first time a view object is updated. This method places
the view in the correct mapping mode and disables the scrollbars. For
more information on mapping modes and views, see the MFC
documentation.
The final part of the skeleton registers the new document template
with the MFC framework. This registration process is simple, just a
matter of calling AddDocTemplate() on the
application object. In addition, this code associates some
doc strings with
the template. These doc strings tell the MFC framework important
details about the document template, such as the file extensions for
the documents, the window title for new documents, etc. For
information on these doc strings, see the PythonWin Reference for the
function PyCDocTemplate.SetDocStrings().
Tip
The term doc strings has a number of meanings. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access