Exemple #1
0
 def __createRuleWidget(self, rule, panel, sizer):
     box = wx.StaticBox(panel, wx.ID_ANY, "RULE")
         
     color = wx.Colour(*confidence_display.getColor(rule.confidence))
     box.SetForegroundColour(color)
     box.SetBackgroundColour(color)
     boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
     
     topLabel = wx.StaticText(panel, label=rule.getRuleString())
     topLabel.SetToolTip(wx.ToolTip(str(rule.quality)))
     boxSizer.Add(topLabel, flag=wx.TOP | wx.BOTTOM | wx.EXPAND, border=3)
     
     boxSizer.Add(wx.StaticLine(panel, style=wx.LI_HORIZONTAL), flag=wx.EXPAND)
     
     for rhs in rule.rhsList:
         label = wx.StaticText(panel, label=rhs.getUnifiedString())
         label.SetBackgroundColour(wx.Color(230, 230, 255))
         # FIXME
         
         if rhs.getToolTipText() is not None:
             label.SetToolTip(wx.ToolTip(str(rhs.getToolTipText())))
         
         if rhs.hasExpansion():
             self.__subArgs[label] = rhs
             label.Bind(wx.EVT_LEFT_DCLICK, self.__expandLabel)
             label.SetBackgroundColour(wx.Color(220, 240, 240))
         boxSizer.Add(label, flag=wx.TOP | wx.BOTTOM | wx.EXPAND, border=3)
         
     boxSizer.Add(wx.StaticLine(panel, style=wx.LI_HORIZONTAL), flag=wx.EXPAND)
     
     endLabel = wx.StaticText(panel, label=rule.getConclusionString())
     boxSizer.Add(endLabel, flag=wx.TOP | wx.EXPAND, border=3)
         
     sizer.Add(boxSizer, flag=wx.EXPAND)
Exemple #2
0
 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)
Exemple #3
0
 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)