def __init__(self, parent=None, associatedWidget=None, orientation=Qt.Horizontal): """ Constructor """ logging.debug("%s: Constructor" % self.__class__.__name__) self._cursorEntered = False self._menuEntryTextFields = [] self._menuEntrySlots = [] self._hoverEntry = None self._spacer = TextField() VispaWidget.__init__(self, parent) self.hide() self._associatedWidget = associatedWidget self.setMouseTracking(True) self.setDragable(False) #self._hoverBrush = QBrush(self.HOVER_COLOR1) self._hoverGradient = QRadialGradient() self._hoverGradient.setColorAt(0, self.HOVER_COLOR1) self._hoverGradient.setColorAt(1, self.HOVER_COLOR2) #self._hoverBrush = QBrush(self.HOVER_COLOR1) self._spacer.setFontSizeRange(self.TEXTFIELD_FONTSIZE_MIN, self.TEXTFIELD_FONTSIZE_MAX) #self._textField.setDefaultWidth(self.getDistance('textFieldWidth', 1, True)) #entry.setDefaultHeight(self.getDistance('textFieldHeight', 1, True)) self._spacer.setDefaultFontSize(self.TEXTFIELD_FONTSIZE) self._spacer.setAutosizeFont(self.TEXTFIELD_AUTOSIZE_FONT_FLAG) self._spacer.setAutotruncate(self.TEXTFIELD_AUTOTRUNCATE_TEXT_FLAG) self._spacer.setAutoscale(True, False) self._spacer.setPenColor(self.TITLE_COLOR) self._spacer.setFont(self.font()) self._spacer.setText(" | ") self._spacer.calculateDimensions()
def addEntry(self, name, slot=None): entry = TextField() entry.setFontSizeRange(self.TEXTFIELD_FONTSIZE_MIN, self.TEXTFIELD_FONTSIZE_MAX) #self._textField.setDefaultWidth(self.getDistance('textFieldWidth', 1, True)) #entry.setDefaultHeight(self.getDistance('textFieldHeight', 1, True)) entry.setDefaultFontSize(self.TEXTFIELD_FONTSIZE) entry.setAutosizeFont(self.TEXTFIELD_AUTOSIZE_FONT_FLAG) entry.setAutotruncate(self.TEXTFIELD_AUTOTRUNCATE_TEXT_FLAG) entry.setAutoscale(True, False) entry.setPenColor(self.TITLE_COLOR) entry.setFont(self.font()) entry.setText(name) entry.calculateDimensions() self._menuEntryTextFields.append(entry) self._menuEntrySlots.append(slot) self.scheduleRearangeContent() return entry