pyface.i_window module

The abstract interface for all pyface top-level windows.

class pyface.i_window.IWindow(adaptee, default=<class 'traits.adaptation.adaptation_error.AdaptationError'>)[source]

Bases: IWidget

The abstract interface for all pyface top-level windows.

A pyface top-level window has no visual representation until it is opened (ie. its ‘control’ trait will be None until it is opened).

position = Tuple()

The position of the window.

size = Tuple()

The size of the window.

title = Str()

The window title.

opened = Event()

The window has been opened.

opening = VetoableEvent()

The window is about to open.

activated = Event()

The window has been activated.

closed = Event()

The window has been closed.

closing = VetoableEvent()

The window is about to be closed.

deactivated = Event()

The window has been deactivated.

open()[source]

Opens the window.

This fires the closing vetoable event, giving listeners the opportunity to veto the opening of the window.

If the window is opened, the opened event will be fired with the IWindow instance as the event value.

Returns

opened – Whether or not the window was opened.

Return type

bool

close(force=False)[source]

Closes the window.

This fires the closing vetoable event, giving listeners the opportunity to veto the closing of the window. If force is True then the window will close no matter what.

If the window is closed, the closed event will be fired with the window object as the event value.

Parameters

force (bool) – Whether the window should close despite vetos.

Returns

closed – Whether or not the window is closed.

Return type

bool

confirm(message, title=None, cancel=False, default=40)[source]

Convenience method to show a confirmation dialog.

Parameters
  • message (str) – The text of the message to display.

  • title (str) – The text of the dialog title.

  • cancel (bool) – True if the dialog should contain a Cancel button.

  • default (NO, YES or CANCEL) – Which button should be the default button.

information(message, title='Information', detail='', informative='', text_format='auto')[source]

Convenience method to show an information message dialog.

Parameters
  • message (str) – The text of the message to display.

  • title (str) – The text of the dialog title.

  • detail (str) – Further details about the message.

  • informative (str) – Explanatory text to display along with the message.

  • text_format (str) – Specifies what text format to use in the resulting message dialog. One of “auto”, “plain”, or “rich”.

warning(message, title='Warning', detail='', informative='', text_format='auto')[source]

Convenience method to show a warning message dialog.

Parameters
  • message (str) – The text of the message to display.

  • title (str) – The text of the dialog title.

  • detail (str) – Further details about the message.

  • informative (str) – Explanatory text to display along with the message.

  • text_format (str) – Specifies what text format to use in the resulting message dialog. One of “auto”, “plain”, or “rich”.

error(message, title='Error', detail='', informative='', text_format='auto')[source]

Convenience method to show an error message dialog.

Parameters
  • message (str) – The text of the message to display.

  • title (str) – The text of the dialog title.

  • detail (str) – Further details about the message.

  • informative (str) – Explanatory text to display along with the message.

  • text_format (str) – Specifies what text format to use in the resulting message dialog. One of “auto”, “plain”, or “rich”.

class pyface.i_window.MWindow[source]

Bases: HasTraits

The mixin class that contains common code for toolkit specific implementations of the IWindow interface.

Implements: close(), confirm(), open() Reimplements: create()

open()[source]

Opens the window.

This fires the closing vetoable event, giving listeners the opportunity to veto the opening of the window.

If the window is opened, the opened event will be fired with the IWindow instance as the event value.

Returns

opened – Whether or not the window was opened.

Return type

bool

close(force=False)[source]

Closes the window.

This fires the closing vetoable event, giving listeners the opportunity to veto the closing of the window. If force is True then the window will close no matter what.

If the window is closed, the closed event will be fired with the window object as the event value.

Parameters

force (bool) – Whether the window should close despite vetos.

Returns

closed – Whether or not the window is closed.

Return type

bool

confirm(message, title=None, cancel=False, default=40)[source]

Convenience method to show a confirmation dialog.

Parameters
  • message (str) – The text of the message to display.

  • title (str) – The text of the dialog title.

  • cancel (bool) – True if the dialog should contain a Cancel button.

  • default (NO, YES or CANCEL) – Which button should be the default button.

information(message, title='Information', detail='', informative='', text_format='auto')[source]

Convenience method to show an information message dialog.

Parameters
  • message (str) – The text of the message to display.

  • title (str) – The text of the dialog title.

  • detail (str) – Further details about the message.

  • informative (str) – Explanatory text to display along with the message.

  • text_format (str) – Specifies what text format to use in the resulting message dialog. One of “auto”, “plain”, or “rich”. Only supported on the qt backend.

warning(message, title='Warning', detail='', informative='', text_format='auto')[source]

Convenience method to show a warning message dialog.

Parameters
  • message (str) – The text of the message to display.

  • title (str) – The text of the dialog title.

  • detail (str) – Further details about the message.

  • informative (str) – Explanatory text to display along with the message.

  • text_format (str) – Specifies what text format to use in the resulting message dialog. One of “auto”, “plain”, or “rich”. Only supported on the qt backend.

error(message, title='Error', detail='', informative='', text_format='auto')[source]

Convenience method to show an error message dialog.

Parameters
  • message (str) – The text of the message to display.

  • title (str) – The text of the dialog title.

  • detail (str) – Further details about the message.

  • informative (str) – Explanatory text to display along with the message.

  • text_format (str) – Specifies what text format to use in the resulting message dialog. One of “auto”, “plain”, or “rich”. Only supported on the qt backend.