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
|
# (C) Copyright 2005-2023 Enthought, Inc., Austin, TX
# All rights reserved.
#
# This software is provided without warranty under the terms of the BSD
# license included in LICENSE.txt and may be redistributed only under
# the conditions described in the aforementioned license. The license
# is also available online at http://www.enthought.com/licenses/BSD.txt
#
# Thanks for using Enthought open source!
from traits.api import (
Any,
DelegatesTo,
HasTraits,
Instance,
Interface,
provides,
)
class ITaskWindowBackend(Interface):
""" The TaskWindow layout interface.
TaskWindow delegates to an ITaskWindowBackend object for toolkit-specific
layout functionality.
"""
#: The root control of the TaskWindow to which the layout belongs.
control = Any()
#: The TaskWindow to which the layout belongs.
window = Instance("pyface.tasks.task_window.TaskWindow")
# ------------------------------------------------------------------------
# 'ITaskWindowBackend' interface.
# ------------------------------------------------------------------------
def create_contents(self, parent):
""" Create and return the TaskWindow's contents. (See IWindow.)
"""
def destroy(self):
""" Destroy the backend.
Note that TaskWindow will destroy the widget created in create_contents,
but this method may be used to perform additional cleanup.
"""
def hide_task(self, state):
""" Assuming the specified TaskState is active, hide its controls.
"""
def show_task(self, state):
""" Assuming no task is currently active, show the controls of the
specified TaskState.
"""
# Methods for saving and restoring the layout -------------------------#
def get_layout(self):
""" Returns a TaskLayout for the current state of the window.
"""
def set_layout(self, layout):
""" Applies a TaskLayout (which should be suitable for the active task)
to the window.
"""
@provides(ITaskWindowBackend)
class MTaskWindowBackend(HasTraits):
""" Mixin containing common coe for toolkit-specific implementations.
"""
# 'ITaskWindowBackend' interface ---------------------------------------
control = DelegatesTo("window")
window = Instance("pyface.tasks.task_window.TaskWindow")
# ------------------------------------------------------------------------
# 'ITaskWindowBackend' interface.
# ------------------------------------------------------------------------
def create_contents(self, parent):
raise NotImplementedError()
def destroy(self):
pass
def hide_task(self, state):
raise NotImplementedError()
def show_task(self, state):
raise NotImplementedError()
def get_layout(self):
raise NotImplementedError()
def set_layout(self, layout):
raise NotImplementedError()
|