def OnItemDocumentation(self, evt): """ Display the item's documentation on miniFrame. """ item = self.GetSelection() path = self.GetItemPyData(item) name = self.GetItemText(item) module = BlockFactory.GetModule(path) info = Container.CheckClass(path) if isinstance(info, tuple): doc = str(info) elif isinstance(module, tuple): doc = str(module) else: doc = inspect.getdoc(module) if doc: dlg = wx.lib.dialogs.ScrolledMessageDialog( self, doc, name, style=wx.OK | wx.ICON_EXCLAMATION | wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) dlg.CenterOnParent(wx.BOTH) dlg.ShowModal() else: wx.MessageBox(_('No documentation'), name, wx.OK | wx.ICON_INFORMATION)
def OnMotion(self, evt): """ Motion engine over item. """ item, flags = self.HitTest(evt.GetPosition()) if (flags & wx.TREE_HITTEST_ONITEMLABEL) and not evt.LeftIsDown(): path = self.GetItemData(item) if os.path.isdir(path): model_list = self.GetModelList(path) domain_list = self.GetDomainList(path) tip = '\n'.join(model_list) if model_list != [] else "" tip += '\n' tip += '\n'.join(domain_list) if domain_list != [] else "" ### is last item else: module = BlockFactory.GetModule(path) info = Container.CheckClass(path) if isinstance(info, tuple): doc = str(info) elif isinstance(module, tuple): doc = str(module) else: doc = inspect.getdoc(module) tip = doc if doc is not None else _( "No documentation for selected model.") ### add maccabe metric info if item in self.MetricDico: mcc = self.MetricDico[item]['mcc'] tip = ''.join([tip, '\n', 'macCabe metric: %d' % mcc]) self.SetToolTip(tip) else: self.SetToolTip(None) ### else the drag and drop dont run evt.Skip()
def OnMotion(self, evt): """ Motion engine over item. """ item, flags = self.HitTest(evt.GetPosition()) if (flags & wx.TREE_HITTEST_ONITEMLABEL) and not evt.LeftIsDown(): path = self.GetItemPyData(item) if os.path.isdir(path): model_list = self.GetModelList(path) domain_list = self.GetDomainList(path) tip = '\n'.join(model_list) if model_list != [] else "" tip += '\n' tip += '\n'.join(domain_list) if domain_list != [] else "" ### is last item else: module = BlockFactory.GetModule(path) info = Container.CheckClass(path) if isinstance(info, tuple): doc = str(info) elif isinstance(module, tuple): doc = str(module) else: doc = inspect.getdoc(module) tip = doc if doc is not None else _( "No documentation for selected model.") try: txt = tip.decode('utf-8', 'ignore') except UnicodeEncodeError: sys.stdout.write("Unicode Error!\n") else: self.SetToolTip(wx.ToolTip(txt)) else: self.SetToolTip(None) ### else the drag and drop dont run evt.Skip()
def OnItemDocumentation(self, evt): """ Display the item's documentation on miniFrame. """ item = self.GetSelection() path = self.GetItemPyData(item) name = self.GetItemText(item) module = BlockFactory.GetModule(path) info = Container.CheckClass(path) if isinstance(info, tuple): doc = str(info) elif isinstance(module, tuple): doc = str(module) else: doc = inspect.getdoc(module) ### Add maccabe complexity measure doc += "".join( [_("\n\n MacCabe Complexity: %d") % self.MetricDico[item]['mcc']]) if doc: dlg = wx.lib.dialogs.ScrolledMessageDialog( self, doc, _("%s Documentation") % name, style=wx.OK | wx.ICON_EXCLAMATION | wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) dlg.CenterOnParent(wx.BOTH) dlg.ShowModal() else: wx.MessageBox( _("No documentation! \n Please define the documentation of the model %s in the header of its python file." ) % name, _("%s Documentation") % name, wx.OK | wx.ICON_INFORMATION)