def GetFilteredConcepts(item): dialog = FilteringDialog() result = dialog.ShowModal() if result == wx.ID_OK: options = dialog.GetOptions() cs = uread_xml(item.path) precessor = item.precessor while not precessor.type == "Context": precessor = precessor.precessor (root, ext) = os.path.splitext(precessor.name) if ext == ".cxt": cxt = fca.read_cxt(precessor.path) elif ext == ".txt": cxt = fca.read_txt(precessor.path) cs.context = cxt new_cs = fca.filter_concepts(cs, options["function"], options["mode"], options["opt"]) default_path = item.path[:-4] + "-filtered.xml" newpath = default_path i = 1 while (os.path.exists(newpath)): newpath = default_path[:-4] + "-{0}".format(i) + newpath[-4:] i += 1 fca.write_xml(newpath, new_cs) newpath = [newpath] else: newpath = [] dialog.Destroy() return newpath
def __init__(self, parent, id, filename, path): """docstring for __init__""" wx.Panel.__init__(self, parent, -1) self.canvas = MyCanvas(self, -1) self.toolBar = self.CreateToolBar() self.toolBar.Realize() self.filename = filename self.path = path self.canvas.SetConceptSystem(uread_xml(path))
def ComputeIndex(self, item, workspace): cs = uread_xml(item.path) functions = filtering.get_compute_functions() dlg = wx.SingleChoiceDialog(None, 'Choose index you want to compute', 'Choose index', functions.keys(), wx.CHOICEDLG_STYLE) if dlg.ShowModal() == wx.ID_OK: name = dlg.GetStringSelection() precessor = item.precessor while not precessor.type == "Context": precessor = precessor.precessor cs.context = fca.read_cxt(precessor.path) fca.compute_index(cs, functions[name], name) fca.write_xml(item.path, cs) dlg.Destroy()
def ComputeIndex(self, item, workspace): cs = uread_xml(item.path) functions = filtering.get_compute_functions() dlg = wx.SingleChoiceDialog( None, 'Choose index you want to compute', 'Choose index', functions.keys(), wx.CHOICEDLG_STYLE ) if dlg.ShowModal() == wx.ID_OK: name = dlg.GetStringSelection() precessor = item.precessor while not precessor.type == "Context": precessor = precessor.precessor cs.context = fca.read_cxt(precessor.path) fca.compute_index(cs, functions[name], name) fca.write_xml(item.path, cs) dlg.Destroy()
def OpenFile(self, item): if item in self._opened_files: self._tabs_view.SetSelection(self._tabs_view.GetPageIndex(self._tabs[item])) elif not item.dir and not item in self._opened_files: self._opened_files.append(item) # then we create new tab in the tabs view if self._tabs_view: if item.type == "Context" or item.type == "Scale": newtab = contextgrid.ContextGrid(self._tabs_view) newtab.SetTable(contextgrid.ContextTable(item, self)) elif item.type == "Many-valued context": newtab = contextgrid.MVContextGrid(self._tabs_view) newtab.SetTable(contextgrid.MVContextTable(item, self)) elif item.type == "Image": png = wx.Image(item.path, wx.BITMAP_TYPE_PNG).ConvertToBitmap() newtab = ScrolledPanel(self._tabs_view, -1) wx.StaticBitmap(newtab, -1, png, (10, 10), (png.GetWidth(), png.GetHeight())) newtab.SetScrollRate(20,20) newtab.SetVirtualSize((png.GetWidth() + 20, png.GetHeight() + 20)) elif item.type == "Concepts": dlg = wx.SingleChoiceDialog( None, 'What do you want to do?', 'Choose variant', ["View diagram", "View concepts", "Table"], wx.CHOICEDLG_STYLE ) if dlg.ShowModal() == wx.ID_OK: what = dlg.GetStringSelection() else: what = "Do nothing" dlg.Destroy() if what == "View concepts": newtab = wx.TextCtrl(self._tabs_view, -1, "", size=(200, 100), style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_WORDWRAP) newtab.SetFont(wx.Font(12, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)) cs = uread_xml(item.path) for concept in cs: s = u"[{0} : {1}] @ {2}\n".format(", ".join(concept.extent), ", ".join(concept.intent), concept.meta) newtab.WriteText(s) elif what == "View diagram": newtab = diagramview.DiagramWindow(self._tabs_view, wx.NewId(), filename=item.name, path=item.path) elif what == "Table": table = conceptsystemgrid.ConceptSystemTable(uread_xml(item.path)) newtab = conceptsystemgrid.ConceptSystemGrid(self._tabs_view) newtab.SetTable(table) elif what == "Do nothing": self._opened_files.pop() return else: newtab = wx.TextCtrl(self._tabs_view, -1, "", size=(200, 100), style=wx.TE_MULTILINE|wx.TE_READONLY) newtab.SetFont(wx.Font(14, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)) newtab.LoadFile(item.path) # TODO: newtab.ref = item self._tabs[item] = newtab self._tabs_view.AddPage(newtab, item.name, True)
def OpenFile(self, item): if item in self._opened_files: self._tabs_view.SetSelection( self._tabs_view.GetPageIndex(self._tabs[item])) elif not item.dir and not item in self._opened_files: self._opened_files.append(item) # then we create new tab in the tabs view if self._tabs_view: if item.type == "Context" or item.type == "Scale": newtab = contextgrid.ContextGrid(self._tabs_view) newtab.SetTable(contextgrid.ContextTable(item, self)) elif item.type == "Many-valued context": newtab = contextgrid.MVContextGrid(self._tabs_view) newtab.SetTable(contextgrid.MVContextTable(item, self)) elif item.type == "Image": png = wx.Image(item.path, wx.BITMAP_TYPE_PNG).ConvertToBitmap() newtab = ScrolledPanel(self._tabs_view, -1) wx.StaticBitmap(newtab, -1, png, (10, 10), (png.GetWidth(), png.GetHeight())) newtab.SetScrollRate(20, 20) newtab.SetVirtualSize( (png.GetWidth() + 20, png.GetHeight() + 20)) elif item.type == "Concepts": dlg = wx.SingleChoiceDialog( None, 'What do you want to do?', 'Choose variant', ["View diagram", "View concepts", "Table"], wx.CHOICEDLG_STYLE) if dlg.ShowModal() == wx.ID_OK: what = dlg.GetStringSelection() else: what = "Do nothing" dlg.Destroy() if what == "View concepts": newtab = wx.TextCtrl(self._tabs_view, -1, "", size=(200, 100), style=wx.TE_MULTILINE | wx.TE_READONLY | wx.TE_WORDWRAP) newtab.SetFont( wx.Font(12, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)) cs = uread_xml(item.path) for concept in cs: s = u"[{0} : {1}] @ {2}\n".format( ", ".join(concept.extent), ", ".join(concept.intent), concept.meta) newtab.WriteText(s) elif what == "View diagram": newtab = diagramview.DiagramWindow(self._tabs_view, wx.NewId(), filename=item.name, path=item.path) elif what == "Table": table = conceptsystemgrid.ConceptSystemTable( uread_xml(item.path)) newtab = conceptsystemgrid.ConceptSystemGrid( self._tabs_view) newtab.SetTable(table) elif what == "Do nothing": self._opened_files.pop() return else: newtab = wx.TextCtrl(self._tabs_view, -1, "", size=(200, 100), style=wx.TE_MULTILINE | wx.TE_READONLY) newtab.SetFont( wx.Font(14, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)) newtab.LoadFile(item.path) # TODO: newtab.ref = item self._tabs[item] = newtab self._tabs_view.AddPage(newtab, item.name, True)