def __makeRulePanel(self, rules): scrolledWindow = wx.ScrolledWindow(self) panel = wx.Panel(scrolledWindow) panel.SetBackgroundColour(wx.WHITE) sizer = wx.BoxSizer(wx.VERTICAL) rules.sort() #mmm, hack. if len(rules) > 0 and not rules[0].confidence.isTrue(): rules.reverse() while len(rules) > 0: conf = rules[-1].confidence innerPanel = wx.Panel(panel) innerSizer = wx.BoxSizer(wx.VERTICAL) size = 10 while len(rules) > 0 and rules[-1].confidence == conf: rule = rules.pop() size += 5 self.__createRuleWidget(rule, innerPanel, innerSizer) index = confidence_display.getIndex(conf) colorPanel = self.__colorPanels[index[0] * confidence.Validity.RANKS + index[1]] colorPanel.SetBackgroundColour(wx.Color(*confidence_display.getColor(conf))) colorPanel.SetSize((size, size)) innerPanel.SetSizer(innerSizer) innerPanel.SetToolTip(wx.ToolTip(str(conf))) sizer.Add(innerPanel) sizer.AddSpacer(30) panel.SetSizer(sizer) sSizer = wx.BoxSizer(wx.HORIZONTAL) sSizer.Add(panel, flag=wx.EXPAND, proportion=1) scrolledWindow.SetSizer(sSizer) scrolledWindow.SetScrollRate(20, 20) scrolledWindow.EnableScrolling(True, True) self.__ruleSizer.Add(scrolledWindow, flag=wx.EXPAND, proportion=1)
def addArgument(arg): index = confidence_display.getIndex(arg.confidence) if index is None: return panel = panels[index[0]][index[1]] if panel is None: panel = wx.Panel(self) panels[index[0]][index[1]] = panel box = wx.StaticBox(panel, wx.ID_ANY, "RULE") color = wx.Colour(*confidence_display.getColor(arg.confidence)) box.SetForegroundColour(color) box.SetBackgroundColour(color) bsizer = wx.StaticBoxSizer(box, wx.VERTICAL) panel.SetSizer(bsizer) sizer.Add(panel, flag=wx.EXPAND, row=index[0], col=index[1]) bsizer = panel.GetSizer() label = wx.StaticText(panel, label=arg.getUnifiedString()) bsizer.Add(label, flag=wx.EXPAND, proportion=1)