1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600
|
.. wxPython Phoenix documentation
This file was generated by Phoenix's sphinx generator and associated
tools, do not edit by hand.
Copyright: (c) 2011-2020 by Total Control Software
License: wxWindows License
.. include:: headings.inc
.. currentmodule:: wx.lib.docview
.. highlight:: python
.. _wx.lib.docview.DocManager:
==========================================================================================================================================
|phoenix_title| **wx.lib.docview.DocManager**
==========================================================================================================================================
The :class:`DocManager` class is part of the document/view framework,
and cooperates with the :class:`View`, :class:`Document` and
:class:`DocTemplate` classes.
|
|class_hierarchy| Class Hierarchy
=================================
.. raw:: html
<div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
<img id="toggleBlock-trigger" src="_static/images/closed.png"/>
Inheritance diagram for class <strong>DocManager</strong>:
</div>
<div id="toggleBlock-summary" style="display:block;"></div>
<div id="toggleBlock-content" style="display:none;">
<p class="graphviz">
<center><img src="_static/images/inheritance/wx.lib.docview.DocManager_inheritance.png" alt="Inheritance diagram of DocManager" usemap="#dummy" class="inheritance"/></center>
<script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
<map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.lib.docview.DocManager.html" title="wx.lib.docview.DocManager" alt="" coords="7,160,210,189"/> <area shape="rect" id="node2" href="wx.EvtHandler.html" title="wx.EvtHandler" alt="" coords="50,83,167,112"/> <area shape="rect" id="node3" href="wx.Object.html" title="wx.Object" alt="" coords="5,5,92,35"/> <area shape="rect" id="node4" href="wx.Trackable.html" title="wx.Trackable" alt="" coords="117,5,223,35"/> </map>
</p>
</div>
|
|super_classes| Known Superclasses
==================================
:class:`wx.EvtHandler`
|
|method_summary| Methods Summary
================================
================================================================================ ================================================================================
:meth:`~wx.lib.docview.DocManager.__init__` Constructor. Create a document manager instance dynamically near the
:meth:`~wx.lib.docview.DocManager.ActivateView` Sets the current view.
:meth:`~wx.lib.docview.DocManager.AddDocument` Adds the document to the list of documents.
:meth:`~wx.lib.docview.DocManager.AddFileToHistory` Adds a file to the file history list, if we have a pointer to an
:meth:`~wx.lib.docview.DocManager.AssociateTemplate` Adds the template to the document manager's template list.
:meth:`~wx.lib.docview.DocManager.Clear` Closes all currently opened document by callling :meth:`~wx.lib.docview.DocManager.CloseDocuments`
:meth:`~wx.lib.docview.DocManager.CloseDocument` Closes the specified document.
:meth:`~wx.lib.docview.DocManager.CloseDocuments` Closes all currently opened documents.
:meth:`~wx.lib.docview.DocManager.CreateDocument` Creates a new document in a manner determined by the flags parameter,
:meth:`~wx.lib.docview.DocManager.CreateView` Creates a new view for the given document. If more than one view is
:meth:`~wx.lib.docview.DocManager.DeleteTemplate` Placeholder, not yet implemented in wxWindows.
:meth:`~wx.lib.docview.DocManager.Destroy` Destructor.
:meth:`~wx.lib.docview.DocManager.DisassociateTemplate` Removes the template from the list of templates.
:meth:`~wx.lib.docview.DocManager.FileHistoryAddFilesToMenu` Appends the files in the history list, to all menus managed by the
:meth:`~wx.lib.docview.DocManager.FileHistoryLoad` Loads the file history from a config object.
:meth:`~wx.lib.docview.DocManager.FileHistoryRemoveMenu` Removes the given menu from the list of menus managed by the file
:meth:`~wx.lib.docview.DocManager.FileHistorySave` Saves the file history into a config object. This must be called
:meth:`~wx.lib.docview.DocManager.FileHistoryUseMenu` Use this menu for appending recently-visited document filenames, for
:meth:`~wx.lib.docview.DocManager.FindSuitableParent` Returns a parent frame or dialog, either the frame with the current
:meth:`~wx.lib.docview.DocManager.FindTemplateForPath` Given a path, try to find template that matches the extension. This is
:meth:`~wx.lib.docview.DocManager.FlushDoc` Placeholder, not yet implemented in wxWindows.
:meth:`~wx.lib.docview.DocManager.GetCurrentDocument` Returns the document associated with the currently active view (if any).
:meth:`~wx.lib.docview.DocManager.GetCurrentView` Returns the currently active view.
:meth:`~wx.lib.docview.DocManager.GetDocuments` Returns the list of documents.
:meth:`~wx.lib.docview.DocManager.GetFileHistory` Returns the file history.
:meth:`~wx.lib.docview.DocManager.GetFlags` Returns the document manager's flags.
:meth:`~wx.lib.docview.DocManager.GetHistoryFile` Returns the file at index i from the file history.
:meth:`~wx.lib.docview.DocManager.GetHistoryFilesCount` Returns the number of files currently stored in the file history.
:meth:`~wx.lib.docview.DocManager.GetLastActiveView` Returns the last active view. This is used in the SDI framework where dialogs can be mistaken for a view
:meth:`~wx.lib.docview.DocManager.GetMaxDocsOpen` Returns the number of documents that can be open simultaneously.
:meth:`~wx.lib.docview.DocManager.GetTemplates` Returns the document manager's template list.
:meth:`~wx.lib.docview.DocManager.Initialize` Initializes data; currently just calls :meth:`OnCreateFileHistory`. Some data
:meth:`~wx.lib.docview.DocManager.MakeDefaultName` Returns a suitable default name. This is implemented by appending an
:meth:`~wx.lib.docview.DocManager.MakeFrameTitle` Returns a suitable title for a document frame. This is implemented by
:meth:`~wx.lib.docview.DocManager.MatchTemplate` Placeholder, not yet implemented in wxWindows.
:meth:`~wx.lib.docview.DocManager.OnCreateFileHistory` A hook to allow a derived class to create a different type of file
:meth:`~wx.lib.docview.DocManager.OnFileClose` Closes and deletes the currently active document.
:meth:`~wx.lib.docview.DocManager.OnFileCloseAll` Closes and deletes all the currently opened documents.
:meth:`~wx.lib.docview.DocManager.OnFileNew` Creates a new document and reads in the selected file.
:meth:`~wx.lib.docview.DocManager.OnFileOpen` Creates a new document and reads in the selected file.
:meth:`~wx.lib.docview.DocManager.OnFileRevert` Reverts the current document by calling wxDocument.Save for the current
:meth:`~wx.lib.docview.DocManager.OnFileSave` Saves the current document by calling :meth:`Document.Save` for
:meth:`~wx.lib.docview.DocManager.OnFileSaveAs` Calls :meth:`Document.SaveAs` for the current document.
:meth:`~wx.lib.docview.DocManager.OnOpenFileFailure` Called when there is an error opening a file.
:meth:`~wx.lib.docview.DocManager.OnPreview` Previews the current document by calling its View's
:meth:`~wx.lib.docview.DocManager.OnPrint` Prints the current document by calling its View's
:meth:`~wx.lib.docview.DocManager.OnPrintSetup` Presents the print setup dialog.
:meth:`~wx.lib.docview.DocManager.OnRedo` Issues a Redo command to the current document's command processor.
:meth:`~wx.lib.docview.DocManager.OnUndo` Issues an Undo command to the current document's command processor.
:meth:`~wx.lib.docview.DocManager.OnUpdateFileClose` Updates the user interface for the File Close command.
:meth:`~wx.lib.docview.DocManager.OnUpdateFileCloseAll` Updates the user interface for the File Close All command.
:meth:`~wx.lib.docview.DocManager.OnUpdateFileNew` Updates the user interface for the File New command.
:meth:`~wx.lib.docview.DocManager.OnUpdateFileOpen` Updates the user interface for the File Open command.
:meth:`~wx.lib.docview.DocManager.OnUpdateFileRevert` Updates the user interface for the File Revert command.
:meth:`~wx.lib.docview.DocManager.OnUpdateFileSave` Updates the user interface for the File Save command.
:meth:`~wx.lib.docview.DocManager.OnUpdateFileSaveAs` Updates the user interface for the File Save As command.
:meth:`~wx.lib.docview.DocManager.OnUpdatePreview` Updates the user interface for the Print Preview command.
:meth:`~wx.lib.docview.DocManager.OnUpdatePrint` Updates the user interface for the Print command.
:meth:`~wx.lib.docview.DocManager.OnUpdatePrintSetup` Updates the user interface for the Print Setup command.
:meth:`~wx.lib.docview.DocManager.OnUpdateRedo` Updates the user interface for the Redo command.
:meth:`~wx.lib.docview.DocManager.OnUpdateUndo` Updates the user interface for the Undo command.
:meth:`~wx.lib.docview.DocManager.ProcessEvent` Processes an event, searching event tables and calling zero or more
:meth:`~wx.lib.docview.DocManager.ProcessUpdateUIEvent` Processes a UI event, searching event tables and calling zero or more
:meth:`~wx.lib.docview.DocManager.RemoveDocument` Removes the document from the list of documents.
:meth:`~wx.lib.docview.DocManager.RemoveFileFromHistory` Removes a file from the file history list, if we have a pointer to an
:meth:`~wx.lib.docview.DocManager.SelectDocumentPath` Under Windows, pops up a file selector with a list of filters
:meth:`~wx.lib.docview.DocManager.SelectDocumentType` Returns a document template by asking the user (if there is more than
:meth:`~wx.lib.docview.DocManager.SelectViewType` Returns a document template by asking the user (if there is
:meth:`~wx.lib.docview.DocManager.SetMaxDocsOpen` Sets the maximum number of documents that can be open at a time. By
================================================================================ ================================================================================
|
|api| Class API
===============
.. class:: DocManager(wx.EvtHandler)
The :class:`DocManager` class is part of the document/view framework,
and cooperates with the :class:`View`, :class:`Document` and
:class:`DocTemplate` classes.
.. method:: __init__(self, flags=DEFAULT_DOCMAN_FLAGS, initialize=True)
Constructor. Create a document manager instance dynamically near the
start of your application before doing any document or view operations.
flags is used in the Python version to indicate whether the document
manager is in DOC_SDI or DOC_MDI mode.
If initialize is true, the Initialize function will be called to
create a default history list object. If you derive from wxDocManager,
you may wish to call the base constructor with false, and then call
Initialize in your own constructor, to allow your own Initialize or
OnCreateFileHistory functions to be called.
.. method:: ActivateView(self, view, activate=True, deleting=False)
Sets the current view.
.. method:: AddDocument(self, document)
Adds the document to the list of documents.
.. method:: AddFileToHistory(self, fileName)
Adds a file to the file history list, if we have a pointer to an
appropriate file menu.
.. method:: AssociateTemplate(self, docTemplate)
Adds the template to the document manager's template list.
.. method:: Clear(self, force=True)
Closes all currently opened document by callling :meth:`CloseDocuments`
and clears the document manager's templates.
.. method:: CloseDocument(self, doc, force=True)
Closes the specified document.
.. method:: CloseDocuments(self, force=True)
Closes all currently opened documents.
.. method:: CreateDocument(self, path, flags=0)
Creates a new document in a manner determined by the flags parameter,
which can be:
``wx.lib.docview.DOC_NEW`` Creates a fresh document.
``wx.lib.docview.DOC_SILENT`` Silently loads the given document file.
If ``wx.lib.docview.DOC_NEW`` is present, a new document will be
created and returned, possibly after asking the user for a template to
use if there is more than one document template. ``If
wx.lib.docview.DOC_SILENT`` is present, a new document will be created
and the given file loaded into it. If neither of these flags is
present, the user will be presented with a file selector for the file
to load, and the template to use will be determined by the extension
(Windows) or by popping up a template choice list (other platforms).
If the maximum number of documents has been reached, this function
will delete the oldest currently loaded document before creating a new
one.
wxPython version supports the document manager's
``wx.lib.docview.DOC_OPEN_ONCE`` and ``wx.lib.docview.DOC_NO_VIEW``
flag.
if ``wx.lib.docview.DOC_OPEN_ONCE`` is present, trying to open the
same file multiple times will just return the same document. if
``wx.lib.docview.DOC_NO_VIEW`` is present, opening a file will
generate the document, but not generate a corresponding view.
.. method:: CreateView(self, doc, flags=0)
Creates a new view for the given document. If more than one view is
allowed for the document (by virtue of multiple templates mentioning
the same document type), a choice of view is presented to the user.
.. method:: DeleteTemplate(self, template, flags)
Placeholder, not yet implemented in wxWindows.
.. method:: Destroy(self)
Destructor.
.. method:: DisassociateTemplate(self, docTemplate)
Removes the template from the list of templates.
.. method:: FileHistoryAddFilesToMenu(self, menu=None)
Appends the files in the history list, to all menus managed by the
file history object.
If menu is specified, appends the files in the history list to the
given menu only.
.. method:: FileHistoryLoad(self, config)
Loads the file history from a config object.
.. method:: FileHistoryRemoveMenu(self, menu)
Removes the given menu from the list of menus managed by the file
history object.
.. method:: FileHistorySave(self, config)
Saves the file history into a config object. This must be called
explicitly by the application.
.. method:: FileHistoryUseMenu(self, menu)
Use this menu for appending recently-visited document filenames, for
convenient access. Calling this function with a valid menu enables the
history list functionality.
Note that you can add multiple menus using this function, to be
managed by the file history object.
.. method:: FindSuitableParent(self)
Returns a parent frame or dialog, either the frame with the current
focus or if there is no current focus the application's top frame.
.. method:: FindTemplateForPath(self, path)
Given a path, try to find template that matches the extension. This is
only an approximate method of finding a template for creating a
document.
Note this wxPython version looks for and returns a default template
if no specific template is found.
.. method:: FlushDoc(self, doc)
Placeholder, not yet implemented in wxWindows.
.. method:: GetCurrentDocument(self)
Returns the document associated with the currently active view (if any).
.. method:: GetCurrentView(self)
Returns the currently active view.
.. method:: GetDocuments(self)
Returns the list of documents.
.. method:: GetFileHistory(self)
Returns the file history.
.. method:: GetFlags(self)
Returns the document manager's flags.
.. method:: GetHistoryFile(self, i)
Returns the file at index i from the file history.
.. method:: GetHistoryFilesCount(self)
Returns the number of files currently stored in the file history.
.. method:: GetLastActiveView(self)
Returns the last active view. This is used in the SDI framework where dialogs can be mistaken for a view
and causes the framework to deactivete the current view. This happens when something like a custom dialog box used
to operate on the current view is shown.
.. method:: GetMaxDocsOpen(self)
Returns the number of documents that can be open simultaneously.
.. method:: GetTemplates(self)
Returns the document manager's template list.
.. method:: Initialize(self)
Initializes data; currently just calls :meth:`OnCreateFileHistory`. Some data
cannot always be initialized in the constructor because the programmer
must be given the opportunity to override functionality. In fact
``Initialize`` is called from the :class:`DocManager` constructor, but this can
be vetoed by passing false to the second argument, allowing the
derived class's constructor to call ``Initialize``, possibly calling a
different :meth:`OnCreateFileHistory` from the default.
The bottom line: if you're not deriving from ``Initialize``, forget it and
construct :class:`DocManager` with no arguments.
.. method:: MakeDefaultName(self)
Returns a suitable default name. This is implemented by appending an
integer counter to the string "Untitled" and incrementing the counter.
.. method:: MakeFrameTitle(self)
Returns a suitable title for a document frame. This is implemented by
appending the document name to the application name.
.. method:: MatchTemplate(self, path)
Placeholder, not yet implemented in wxWindows.
.. method:: OnCreateFileHistory(self)
A hook to allow a derived class to create a different type of file
history. Called from :meth:`Initialize`.
.. method:: OnFileClose(self, event)
Closes and deletes the currently active document.
.. method:: OnFileCloseAll(self, event)
Closes and deletes all the currently opened documents.
.. method:: OnFileNew(self, event)
Creates a new document and reads in the selected file.
.. method:: OnFileOpen(self, event)
Creates a new document and reads in the selected file.
.. method:: OnFileRevert(self, event)
Reverts the current document by calling wxDocument.Save for the current
document.
.. method:: OnFileSave(self, event)
Saves the current document by calling :meth:`Document.Save` for
the current document.
.. method:: OnFileSaveAs(self, event)
Calls :meth:`Document.SaveAs` for the current document.
.. method:: OnOpenFileFailure(self)
Called when there is an error opening a file.
.. method:: OnPreview(self, event)
Previews the current document by calling its View's
:meth:`~View.OnCreatePrintout` method.
.. method:: OnPrint(self, event)
Prints the current document by calling its View's
:meth:`~View.OnCreatePrintout` method.
.. method:: OnPrintSetup(self, event)
Presents the print setup dialog.
.. method:: OnRedo(self, event)
Issues a Redo command to the current document's command processor.
.. method:: OnUndo(self, event)
Issues an Undo command to the current document's command processor.
.. method:: OnUpdateFileClose(self, event)
Updates the user interface for the File Close command.
.. method:: OnUpdateFileCloseAll(self, event)
Updates the user interface for the File Close All command.
.. method:: OnUpdateFileNew(self, event)
Updates the user interface for the File New command.
.. method:: OnUpdateFileOpen(self, event)
Updates the user interface for the File Open command.
.. method:: OnUpdateFileRevert(self, event)
Updates the user interface for the File Revert command.
.. method:: OnUpdateFileSave(self, event)
Updates the user interface for the File Save command.
.. method:: OnUpdateFileSaveAs(self, event)
Updates the user interface for the File Save As command.
.. method:: OnUpdatePreview(self, event)
Updates the user interface for the Print Preview command.
.. method:: OnUpdatePrint(self, event)
Updates the user interface for the Print command.
.. method:: OnUpdatePrintSetup(self, event)
Updates the user interface for the Print Setup command.
.. method:: OnUpdateRedo(self, event)
Updates the user interface for the Redo command.
.. method:: OnUpdateUndo(self, event)
Updates the user interface for the Undo command.
.. method:: ProcessEvent(self, event)
Processes an event, searching event tables and calling zero or more
suitable event handler function(s). Note that the ProcessEvent
method is called from the wxPython docview framework directly since
wxPython does not have a virtual ProcessEvent function.
.. method:: ProcessUpdateUIEvent(self, event)
Processes a UI event, searching event tables and calling zero or more
suitable event handler function(s).
.. method:: RemoveDocument(self, doc)
Removes the document from the list of documents.
.. method:: RemoveFileFromHistory(self, i)
Removes a file from the file history list, if we have a pointer to an
appropriate file menu.
.. method:: SelectDocumentPath(self, templates, flags, save)
Under Windows, pops up a file selector with a list of filters
corresponding to document templates. The wxDocTemplate corresponding
to the selected file's extension is returned.
On other platforms, if there is more than one document template a
choice list is popped up, followed by a file selector.
This function is used in :meth:`DocManager.CreateDocument`.
.. method:: SelectDocumentType(self, temps, sort=False)
Returns a document template by asking the user (if there is more than
one template). This function is used in :methW`DocManager.CreateDocument`.
Parameters
templates - list of templates from which to choose a desired template.
sort - If more than one template is passed in in templates, then this
parameter indicates whether the list of templates that the user will
have to choose from is sorted or not when shown the choice box dialog.
Default is false.
.. method:: SelectViewType(self, temps, sort=False)
Returns a document template by asking the user (if there is
more than one template), displaying a list of valid views.
This function is used in wxDocManager::CreateView. The dialog
normally will not appear because the array of templates only
contains those relevant to the document in question, and
often there will only be one such.
.. method:: SetMaxDocsOpen(self, maxDocsOpen)
Sets the maximum number of documents that can be open at a time. By
default, this is 10,000. If you set it to 1, existing documents will
be saved and deleted when the user tries to open or create a new one
(similar to the behaviour of Windows Write, for example). Allowing
multiple documents gives behaviour more akin to MS Word and other
Multiple Document Interface applications.
|