def getUpdatePrefix(self, widget, oldState, state):
     if isinstance(widget, self.getTextEntryClass()):
         return "\nUpdated " + (util.getTextLabel(widget) or "Text") +  " Field\n"
     elif isinstance(widget, swt.widgets.Combo):
         return "\nUpdated " + util.getTextLabel(widget) + " Combo Box\n"
     elif util.getTopControl(widget):
         return "\n"
     elif isinstance(widget, swt.widgets.Menu):
         return "\nUpdated " + widget.getParentItem().getText() + " Menu:\n"
     elif isinstance(widget, (swt.widgets.Label, swt.custom.CLabel)) and len(state) == 0:
         return "\nLabel now empty, previously " + oldState
     else:
         return "\nUpdated "
    def getChildrenDescription(self, widget):
        # DateTime children are an implementation detail
        # Coolbars and Expandbars describe their children directly : they have two parallel children structures
        # Composites with StackLayout use the topControl rather than the children
        if not isinstance(widget, swt.widgets.Composite) or \
               isinstance(widget, (swt.widgets.CoolBar, swt.widgets.ExpandBar, swt.widgets.DateTime)) or \
               util.getTopControl(widget):
            return ""

        children = self.sortChildren(widget)
        childDescriptions = map(self.getDescription, children)
        columns = self.getLayoutColumns(widget, childDescriptions)
        if columns > 1:
            horizontalSpans = map(self.getHorizontalSpan, children)
            return self.formatInGrid(childDescriptions, columns, horizontalSpans)
        else:
            return self.formatInColumn(childDescriptions)
        return self.formatChildrenDescriptions(widget, children)
Beispiel #3
0
 def getUpdatePrefix(self, widget, oldState, state):
     if isinstance(widget, (self.getTextEntryClass(), Browser, Spinner)):
         return "\nUpdated " + (util.getTextLabel(widget, useContext=True) or self.getShortWidgetIdentifier(widget) or "Text") +  " Field\n"
     elif isinstance(widget, (Combo, CCombo)):
         return "\nUpdated " + util.getTextLabel(widget, useContext=True) + " Combo Box\n"
     elif util.getTopControl(widget) or isinstance(widget, Group):
         return "\n"
     elif isinstance(widget, Menu):
         parentItem = widget.getParentItem()
         menuRefNr = self.contextMenuCounter.getWidgetNumber(widget)
         menuRefNr = " " + str(menuRefNr) if menuRefNr > 0 else ""
         menuName = parentItem.getText() if parentItem else "Context"
         return "\nUpdated " + menuName + " Menu" + menuRefNr +":\n"
     elif isinstance(widget, (Label, CLabel)) and len(state) == 0:
         return "\nLabel now empty, previously " + oldState
     elif isinstance(widget, Canvas) and not isinstance(widget, CLabel):
         for canvasDescriberClass in self.canvasDescriberClasses:
             if canvasDescriberClass.canDescribe(widget):
                 return canvasDescriberClass(widget).getUpdatePrefix(oldState, state)
     
     return "\nUpdated "
 def getCompositeState(self, widget):
     return util.getTopControl(widget)
 def shouldDescribeChildren(self, widget):
     # Composites with StackLayout use the topControl rather than the children
     return storytext.guishared.Describer.shouldDescribeChildren(self, widget) and not util.getTopControl(widget)