def _onProjectTreeSelChanged(self, event: TreeEvent): """ Callback for notebook page changed Args: event: """ itm: TreeItemId = event.GetItem() pyutData: TreeDataType = self.__projectTree.GetItemData(itm) self.logger.debug(f'Clicked on: {itm=} `{pyutData=}`') # Use our own base type if isinstance(pyutData, UmlDiagramsFrame): frame: UmlDiagramsFrame = pyutData self._currentFrame = frame self._currentProject = self.getProjectFromFrame(frame) self.__syncPageFrameAndNotebook(frame=frame) elif isinstance(pyutData, PyutProject): project: PyutProject = pyutData projectFrames: List[UmlFrameType] = project.getFrames() if len(projectFrames) > 0: self._currentFrame = projectFrames[0] self.__syncPageFrameAndNotebook(frame=self._currentFrame) self._mediator.updateTitle() self._currentProject = project
def item_tooltip(self, e: wx.TreeEvent): view: WxPythonView = self.__tree_ctrl.GetItemData(e.GetItem()) if view is not None: if self.__tooltip_timer is not None: self.__tooltip_timer.Stop() self.__tooltip_timer = None self.__tooltip_timer = wx.CallLater(500, self.__tree_ctrl.SetToolTip, self.__labels.get_tooltip(view.get_type_info()))
def __onProjectTreeRightClick(self, treeEvent: TreeEvent): itemId: TreeItemId = treeEvent.GetItem() data = self.__projectTree.GetItemData(item=itemId) self.logger.info(f'Item Data: `{data}`') if isinstance(data, PyutProject): self.__popupProjectMenu() elif isinstance(data, UmlDiagramsFrame): self.__popupProjectDocumentMenu()
def item_right_clicked(self, e: wx.TreeEvent): class RightClickMenu(wx.Menu): def __init__(self, parent): super(RightClickMenu, self).__init__() self.parent = parent self.expand = self.Append(wx.NewId(), 'Expand') self.expand_all = self.Append(wx.NewId(), 'Expand all') self.AppendSeparator() self.collapse = self.Append(wx.NewId(), 'Collapse') self.collapse_all = self.Append(wx.NewId(), 'Collapse all') self.item_selected(e) menu = RightClickMenu(self.__tree_ctrl.GetTopLevelParent()) menu.Bind(wx.EVT_MENU, lambda _: self.__tree_ctrl.ExpandAllChildren(e.GetItem()), menu.expand) menu.Bind(wx.EVT_MENU, lambda _: self.__tree_ctrl.ExpandAll(), menu.expand_all) menu.Bind(wx.EVT_MENU, lambda _: (self.__tree_ctrl.CollapseAllChildren(e.GetItem()), self.__show_view(self.__tree_ctrl.GetItemData(self.__tree_ctrl.GetSelection()))), menu.collapse) menu.Bind(wx.EVT_MENU, lambda _: (self.__tree_ctrl.CollapseAll(), self.__show_view(None)), menu.collapse_all) self.__tree_ctrl.GetTopLevelParent().PopupMenu(menu, e.GetPoint())
def __onProjectTreeSelChanged(self, event: TreeEvent): """ Callback for notebook page changed Args: event: """ itm: TreeItemId = event.GetItem() pyutData: TreeDataType = self.__projectTree.GetItemData(itm) self.logger.debug(f'Clicked on: `{pyutData}`') # Use our own base type if isinstance(pyutData, UmlDiagramsFrame): frame: UmlDiagramsFrame = pyutData self._currentFrame = frame self._currentProject = self.getProjectFromFrame(frame) # Select the frame in the notebook for i in range(self.__notebook.GetPageCount()): pageFrame = self.__notebook.GetPage(i) if pageFrame is frame: self.__notebook.SetSelection(i) return elif isinstance(pyutData, PyutProject): self._currentProject = pyutData
def open_item(self, evt: wx.TreeEvent): item: wx.TreeItemId = evt.GetItem() if item != self.rootItem: path: list = self.treeCtrl.GetItemData(item)["path"] # print(self.get_value(path, self.data)) self.change_value(path, item)
def item_selected(self, e: wx.TreeEvent): view = self.__tree_ctrl.GetItemData(e.GetItem()) self.__show_view(view)