Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
from .task_window_event import TaskWindowEvent
from pyface.tasks.task_window_layout import TaskWindowLayout
window = self.window_factory(application=self, **traits)
# Listen for the window events.
window.on_trait_change(self._on_window_activated, "activated")
window.on_trait_change(self._on_window_opening, "opening")
window.on_trait_change(self._on_window_opened, "opened")
window.on_trait_change(self._on_window_closing, "closing")
window.on_trait_change(self._on_window_closed, "closed")
# Event notification.
self.window_created = TaskWindowEvent(window=window)
if layout:
# Create and add tasks.
for task_id in layout.get_tasks():
task = self.create_task(task_id)
if task:
window.add_task(task)
else:
logger.error(
"Missing factory for task with ID %r", task_id
)
# Apply a suitable layout.
if restore:
layout = self._restore_layout_from_state(layout)
else:
def _on_window_opened(self, window, trait_name, event):
from .task_window_event import TaskWindowEvent
self.windows.append(window)
# Event notification.
self.window_opened = TaskWindowEvent(window=window)
def _on_window_closed(self, window, trait_name, event):
self.windows.remove(window)
# Event notification.
self.window_closed = TaskWindowEvent(window=window)
# Was this the last window?
if len(self.windows) == 0 and self._explicit_exit:
self.stop()
def _on_window_closed(self, window, trait_name, event):
self.windows.remove(window)
# Event notification.
self.window_closed = TaskWindowEvent(window=window)
# Was this the last window?
if len(self.windows) == 0:
self.stop()
def _on_window_closed(self, window, trait_name, event):
from .task_window_event import TaskWindowEvent
self.windows.remove(window)
# Event notification.
self.window_closed = TaskWindowEvent(window=window)
# Was this the last window?
if len(self.windows) == 0:
self.stop()
# Enthought library imports.
from traits.api import HasTraits, Instance, Vetoable
# Local imports.
from .task_window import TaskWindow
class TaskWindowEvent(HasTraits):
""" A task window lifecycle event.
"""
# The window that the event occurred on.
window = Instance(TaskWindow)
class VetoableTaskWindowEvent(TaskWindowEvent, Vetoable):
""" A vetoable task window lifecycle event.
"""
pass
def _on_window_closed(self, window, trait_name, event):
self.windows.remove(window)
# Event notification.
self.window_closed = TaskWindowEvent(window=window)
# Was this the last window?
if len(self.windows) == 0 and self._explicit_exit:
self.stop()