################### # Gui Data Types ################### # from GuiType import (_GuiForm,_GuiFormMulti,_GuiTreeRow,_GuiTree,_GuiWinText, # _GuiWinLinedText,_GuiWinForm,_GuiWinFormMulti,_GuiWinTree,_GuiSideBar, # _GuiMessage, _GuiMessages,) __all__ = ["_GuiForm","_GuiFormMulti","_GuiTreeRow","_GuiTree","_GuiWinText", "_GuiWinLinedText","_GuiWinForm","_GuiWinFormMulti","_GuiWinTree","_GuiSideBar", "_GuiMessage", "_GuiMessages",] class _GuiForm(): def __init__(self, fixed_row, rows): self.FixedRow = fixed_row self.Rows = rows # Form = _GuiForm( ["Col1", "Col2"], [["a1","a2"],["b1","b2"],["c1","c2"]]) class _GuiFormMulti(): def __init__(self, name_forms): self.Names = [] self.__Forms = [] for nf in name_forms: self.Names.append(nf[0]) self.__Forms.append(nf[1]) def GetForm(self, index): # can be further modify to lazy eval return self.__Forms[index] # Forms = _GuiFormMulti([["Sheet1", _GuiForm( ["Col1", "Col2"], [["a1","a2"],["b1","b2"],["c1","c2"]])], ["Sheet2", _GuiForm( ["Col1", "Col2"], [["d1","d2"],["e1","e2"],["f1","f2"]])]]) class _GuiTreeRow(): def __init__(self, treerows, name, row): self.Name = name self.Row = row if treerows: self.HasSubTreeRows = True self.__SubTreeRows = treerows else: self.HasSubTreeRows = False self.__SubTreeRows = [] def GetSubTreeRows(self): return self.__SubTreeRows def GetID(self): pass # TreeRow = _GuiTreeRow([], "SubDesign1", ["12", "0"]) # TreeRow = _GuiTreeRow([_GuiTreeRow([], "Sub3", ["5", "0"])], "SubDesign2", ["34", "1"]) class _GuiTree(): def __init__(self, fixed_row, treerows:_GuiTreeRow): self.FixedRow = fixed_row self.TreeRows = treerows # Tree = _GuiTree(["","DFFs","SubModules"], [_GuiTreeRow([_GuiTreeRow([], "SubDesign1", ["12", "0"]),_GuiTreeRow([_GuiTreeRow([], "Sub3", ["5", "0"])], "SubDesign2", ["34", "1"])], "DemoDesign", ["123", "2"]),]) ##################### # Gui Window Types ##################### class _GuiWinText(): def __init__(self, title, text): self.Title = title self.Text = text class _GuiWinLinedText(): def __init__(self, title, lined_text, line): self.Title = title self.LinedText = lined_text self.GotoLine = line class _GuiWinForm(): def __init__(self, title, form): self.Title = title self.Form = form class _GuiWinFormMulti(): def __init__(self, title, forms): self.Title = title self.Forms = forms class _GuiWinTree(): def __init__(self, tree): self.Title = "" self.Tree = tree class _GuiSideBar(): def __init__(self, title, tree:_GuiTree): self.Title = title self.Tree = tree def GetForms(self, treenames): return _GuiFormMulti([["Sheet1", _GuiForm(["Col1", "Col2"], [[treename, "ok"] for treename in treenames])], ["Sheet2", _GuiForm(["Col1", "Col2"], [[treename, "fail"] for treename in treenames])]]) def CrossProbe(self, treenames, formname, formrow): assert isinstance(treenames, list) assert isinstance(formname, str) or isinstance(formname, type(None)) assert isinstance(formrow, list) line = 1000 return _GuiWinLinedText(str(formrow), ("Text Start\n\n"+'\n'.join(['generated line '+str(x) for x in range(3, line*2)])+'\n'.join([str(x) for x in treenames])+str(formname)+"\n\nText End").split("\n"), line) def Properties(self, treenames, formname, formrow): assert isinstance(treenames, list) assert isinstance(formname, (str, type(None))) assert isinstance(formrow, list) return _GuiWinForm(str(formname)+" Properties", _GuiForm(["Name", "Property"], [[x, "property"] for x in treenames+formrow])) class _GuiMessage(): # _GuiMessage("This is an error!!!", 100, "/x/xx.v") def __init__(self, text, line, filepath): self.Text = text self.Line = line self.FilePath = filepath def GetHint(self): return "line: "+str(self.Line)+", file: "+self.FilePath def CrossProbe(self): return _GuiWinLinedText(self.FilePath, ("Text Start\n\n"+'\n'.join(['generated line '+str(x) for x in range(3, self.Line*2)])+"\n\nText End").split("\n"), self.Line) def Properties(self): return _GuiWinForm("Message Properties", _GuiForm(["Name", "Property"], [["File", self.FilePath], ["Line", str(self.Line)]])) class _GuiMessages(): # _GuiMessages([["Err-123","This is an error",[_GuiMessage("This is an error!", 100, "/x/x.v"),_GuiMessage("This is an error!!", 200, "/xx/xx.v")]]]) def __init__(self, id_messages): self.Size = 0 self._summary = [] self._messages = {} for idm in id_messages: assert len(idm) == 3 assert isinstance(idm[0], str) and idm[0] != "" # "Err-123" assert isinstance(idm[1], str) # "This is an error" assert isinstance(idm[2], list) and len(idm[2]) > 0 # [_GuiMessage(), _GuiMessage()] self.Size += len(idm[2]) self._summary.append([idm[0], len(idm[2]), idm[1]]) self._messages[idm[0]] = idm[2] def GetSummary(self): # [["Err-123", 2, "This is an error"],] return self._summary def GetMsgByID(self, ID): # [_GuiMessage(), _GuiMessage()] return self._messages[ID]