class PyValve(PychronApplication): id = 'pychron.valve.application' name = 'pyValve' default_layout = [ TaskWindowLayout('tasks.hardware'), TaskWindowLayout('pychron.extraction_line'), ]
def _default_layout_default(self): from pyface.tasks.task_window_layout import TaskWindowLayout window_layout = TaskWindowLayout() if self.task_factories: window_layout.items = [self.task_factories[0].id] return [window_layout]
class PyUV(PychronApplication): id = 'pychron.uv.application' name = 'pyUV' default_layout = [ TaskWindowLayout('tasks.hardware'), TaskWindowLayout('pychron.fusions.uv'), ]
class PyCO2(PychronApplication): id = 'pychron.co2.application' name = 'pyCO2' shortname = 'co2' default_layout = [ TaskWindowLayout('tasks.hardware'), TaskWindowLayout('pychron.fusions.co2')]
def _layout_default(self): if self.application.default_layout: layout = self.application.default_layout[0] else: layout = TaskWindowLayout() if self.task_factories: layout.items = [self.task_factories[0].id] return layout
class PyDiode(PychronApplication): id = 'pychron.diode.application' name = 'pyDiode' shortname = 'diode' default_layout = [ TaskWindowLayout('tasks.hardware'), TaskWindowLayout('pychron.fusions.diode') ]
def get_window_layout(self): """ Returns a TaskWindowLayout for the current state of the window. """ result = TaskWindowLayout(position=self.position, size=self.size, size_state=self.size_state) for state in self._states: if state == self._active_state: result.active_task = state.task.id layout = self._window_backend.get_layout() else: layout = state.layout.clone_traits() layout.id = state.task.id result.items.append(layout) return result
def create_window(self, layout=None, restore=True, **traits): """Creates a new TaskWindow, possibly with some Tasks. Parameters: ----------- layout : TaskWindowLayout, optional The layout to use for the window. The tasks described in the layout will be created and added to the window automatically. If not specified, the window will contain no tasks. restore : bool, optional (default True) If set, the application will restore old size and positions for the window and its panes, if possible. If a layout is not provided, this parameter has no effect. **traits : dict, optional Additional parameters to pass to ``window_factory()`` when creating the TaskWindow. Returns: -------- The new TaskWindow. """ 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: # Create an empty layout to set default size and position only layout = TaskWindowLayout() window.set_window_layout(layout) return window
def create_window(self, layout=None, **kwargs): """ Connect task to application and open task in a new window. Parameters ---------- layout : TaskLayout instance or None The pane layout for the window. **kwargs : dict Additional keyword arguments to pass to the window factory. Returns ------- window : ITaskWindow instance or None The new TaskWindow. """ from pyface.tasks.task_window_layout import TaskWindowLayout window = super(TasksApplication, self).create_window(**kwargs) if layout is not None: for task_id in layout.get_tasks(): task = self.create_task(task_id) if task is not None: window.add_task(task) else: msg = "Missing factory for task with ID %r" logger.error(msg, task_id) else: # Create an empty layout to set default size and position only layout = TaskWindowLayout() window.set_window_layout(layout) return window
def get_open_task(self, tid): for win in self.windows: if win.active_task: if win.active_task.id == tid: return win, win.active_task, True else: win = self.create_window(TaskWindowLayout(tid)) return win, win.active_task, False
class PyCO2(PychronApplication): id = 'pychron.co2.application' name = 'pyCO2' default_layout = [ TaskWindowLayout('tasks.hardware'), # TaskWindowLayout( # 'pychron.fusions.diode'), ]
def perform(self, event): if event.task.id == EXP_ID: event.task.new() else: application = event.task.window.application win = application.create_window(TaskWindowLayout(EXP_ID)) task = win.active_task if task.new(): win.open()
def perform(self, event): if event.task.id == self.task_id: task = event.task task.open() else: application = event.task.window.application win = application.create_window(TaskWindowLayout(self.task_id)) task = win.active_task if task.open(path=self.test_path): win.open()
def perform(self, event): if event.task.id == 'pychron.pyscript': task = event.task task.new() else: application = event.task.window.application win = application.create_window(TaskWindowLayout('pychron.pyscript')) task = win.active_task if task.new(): win.open()
def perform(self, event): if event.task.id == 'pychron.pyscript': task = event.task task.open() else: application = event.task.window.application win = application.create_window(TaskWindowLayout('pychron.pyscript', size=(1200, 100) )) task = win.active_task test_path='/Users/ross/Pychrondata_dev/scripts/extraction/jan_pause.py' # test_path='/Users/ross/Pychrondata_dev/scripts/measurement/jan_unknown.py' if task.open(path=test_path): win.open()
def get_task(self, tid, activate=True): for win in self.windows: if win.active_task: if win.active_task.id == tid: if activate and win.control: win.activate() break else: win = self.create_window(TaskWindowLayout(tid)) if activate: win.open() if win: return win.active_task
def perform(self, event): app = self.task.window.application win = app.create_window(TaskWindowLayout(self.task.id)) win.open()
def _default_layout_default(self): return [TaskWindowLayout('wellpy.task', size=(800, 600))]