def create_initial_layout(self, parent): """ Create the initial window layout. """ # The view dock window is where all of the views live. It also contains # a nested dock window where all of the editors live. self._wx_view_dock_window = WorkbenchDockWindow(parent) # The editor dock window (which is nested inside the view dock window) # is where all of the editors live. self._wx_editor_dock_window = WorkbenchDockWindow( self._wx_view_dock_window.control ) editor_dock_window_sizer = DockSizer(contents=DockSection()) self._wx_editor_dock_window.control.SetSizer(editor_dock_window_sizer) # Nest the editor dock window in the view dock window. editor_dock_window_control = DockControl( id = self.editor_area_id, name = 'Editors', control = self._wx_editor_dock_window.control, style = 'fixed', width = self.window.editor_area_size[0], height = self.window.editor_area_size[1], ) view_dock_window_sizer = DockSizer( contents=[editor_dock_window_control] ) self._wx_view_dock_window.control.SetSizer(view_dock_window_sizer) return self._wx_view_dock_window.control
def init(self, parent): """ Finishes initializing the editor by creating the underlying toolkit widget. """ self._uis = [] # Create a DockWindow to hold each separate object's view: theme = self.factory.dock_theme or self.item.container.dock_theme dw = DockWindow(parent, theme=theme) self.control = dw.control self._sizer = DockSizer(DockSection(dock_window=dw)) self.control.SetSizer(self._sizer) # Set up the additional 'list items changed' event handler needed for # a list based trait. Note that we want to fire the update_editor_item # only when the items in the list change and not when intermediate # traits change. Therefore, replace "." by ":" in the extended_name # when setting up the listener. extended_name = self.extended_name.replace('.', ':') self.context_object.on_trait_change( self.update_editor_item, extended_name + '_items?', dispatch='ui') # Set of selection synchronization: self.sync_value(self.factory.selected, 'selected')
def add_dock_window_splitter_items(self, window, content, group): """ Adds a set of groups or items separated by splitter bars to a DockWindow. """ contents = [self.add_dock_window_splitter_item(window, item, group) for item in content] # Create a splitter group to hold the contents: result = DockSection(contents=contents, is_row=self.is_horizontal) # If nothing is resizable, then mark each DockControl as such: if not self.resizable: for item in result.get_controls(): item.resizable = False # Return the DockSection we created: return result
def init(self, parent): """ Finishes initializing the editor by creating the underlying toolkit widget. """ self._uis = [] # Create a DockWindow to hold each separate object's view: theme = self.factory.dock_theme or self.item.container.dock_theme dw = DockWindow(parent, theme=theme) self.control = dw.control self._sizer = DockSizer(DockSection(dock_window=dw)) self.control.SetSizer(self._sizer) # Set up the additional 'list items changed' event handler needed for # a list based trait: self.context_object.on_trait_change(self.update_editor_item, self.extended_name + '_items?', dispatch='ui') # Set of selection synchronization: self.sync_value(self.factory.selected, 'selected')
def create_notebook_for_items( content, ui, parent, group, item_handler=None, is_dock_window=False ): """ Creates a notebook and adds a list of groups or items to it as separate pages. """ if is_dock_window: nb = parent else: dw = DockWindow( parent, handler=ui.handler, handler_args=(ui.info,), id=ui.id ) if group is not None: dw.theme = group.dock_theme nb = dw.control pages = [] count = 0 # Create a notebook page for each group or item in the content: active = 0 for index, item in enumerate(content): if isinstance(item, Group): # Create the group as a nested DockWindow item: if item.selected: active = index sg_sizer, resizable, contents = fill_panel_for_group( nb, item, ui, suppress_label=True, is_dock_window=True ) # If the result is a region (i.e. notebook) with only one page, # collapse it down into just the contents of the region: if isinstance(contents, DockRegion) and ( len(contents.contents) == 1 ): contents = contents.contents[0] # Add the content to the notebook as a new page: pages.append(contents) else: # Create the new page as a simple DockControl containing the # specified set of controls: page_name = item.get_label(ui) count += 1 if page_name == "": page_name = "Page %d" % count sizer = wx.BoxSizer(wx.VERTICAL) panel = TraitsUIPanel(nb, -1) panel.SetSizer(sizer) pages.append( DockControl( name=page_name, image=item.image, id=item.get_id(), style=item.dock, dockable=DockableViewElement(ui=ui, element=item), export=item.export, control=panel, ) ) item_handler(item, panel, sizer) panel.GetSizer().Fit(panel) region = DockRegion(contents=pages, active=active) # If the caller is a DockWindow, return the region as the result: if is_dock_window: return region nb.SetSizer(DockSizer(contents=DockSection(contents=[region]))) # Return the notebook as the result: return nb