Skip to content
Toga
0.5.3.dev143+gabcc6cdb6

DocumentWindow

A window that can be used as the main interface to a document-based app.

/reference/images/mainwindow-cocoa.png

/reference/images/mainwindow-gtk.png

/reference/images/mainwindow-winforms.png

Not supported

Not supported

Not supported

Not supported

Usage

A DocumentWindow is the same as a toga.MainWindow, except that it is bound to a toga.Document instance, exposed as the toga.DocumentWindow.doc attribute.

Instances of toga.DocumentWindow should be created as part of the create() method of an implementation of toga.Document.

Reference

toga.DocumentWindow

DocumentWindow(doc, *args, **kwargs)

Bases: MainWindow

Create a new document Window.

A document window is a MainWindow (so it will have a menu bar, and can have a toolbar), bound to a document instance.

In addition to the required doc argument, accepts the same arguments as Window.

The default on_close handler will use the document's modification status to determine if the document has been modified. It will allow the window to close if the document is fully saved, or the user explicitly declines the opportunity to save.

PARAMETER DESCRIPTION
doc

The document being managed by this window

TYPE: Document

doc property

doc

The document displayed by this window.

save async

save()

Save the document associated with this window.

If the document associated with a window hasn't been saved before, the user will be prompted to provide a filename.

RETURNS DESCRIPTION

True if the save was successful; False if the save was aborted, or the document type doesn't define a Document.write() method.

save_as async

save_as()

Save the document associated with this window under a new filename.

The default implementation will prompt the user for a new filename, then save the document with that new filename.

RETURNS DESCRIPTION

True if the save was successful; False if the save was aborted, or the document type doesn't define a Document.write() method.