def drawDynamicText(self, painter): sineTable = (0, 38, 71, 92, 100, 92, 71, 38, 0, -38, -71, -92, -100, -92, -71, -38) metrics = QtGui.QFontMetrics(self.font()) x = (self.width() - metrics.width(self.text)) / 2 y = (self.height() + metrics.ascent() - metrics.descent()) / 2 color = QtGui.QColor() for i, ch in enumerate(self.text): index = (self.step + i) % 16 color.setHsv((15 - index) * 16, 255, 191) painter.setPen(color) painter.drawText(x, y - ((sineTable[index] * metrics.height()) / 400), ch) x += metrics.width(ch)
def __init__(self, root_obj, root_obj_name='', attr_cols=None, show_routine_attributes=True, show_special_attributes=True, parent=None): """ Constructor :param obj: any Python object or variable :param name: name of the object as it will appear in the root node If empty, no root node drawn. :param attr_cols: list of AttributeColumn definitions :param show_routine_attributes: if True the callables objects, i.e. objects (such as function) that a __call__ method, will be displayed (in brown). If False they are hidden. :param show_special_attributes: if True the objects special attributes, i.e. methods with a name that starts and ends with two underscores, will be displayed (in italics). If False they are hidden. :param parent: the parent widget """ super(TreeModel, self).__init__(parent) self._root_obj = root_obj self._root_name = root_obj_name self._attr_cols = attr_cols self._show_callables = show_routine_attributes self._show_special_attributes = show_special_attributes self.root_item = self.populateTree(root_obj, root_obj_name, ) self.regular_font = QtGui.QFont() # Font for members (non-functions) self.special_attribute_font = QtGui.QFont() # Font for __special_attributes__ self.special_attribute_font.setItalic(True) self.regular_color = QtGui.QBrush(QtGui.QColor('black')) #self.routine_color = QtGui.QBrush(QtGui.QColor('brown')) # for functions, methods, etc. self.routine_color = QtGui.QBrush(QtGui.QColor('mediumblue') ) # for functions, methods, etc.
def set_painterpencolor(self, painter): color = QtGui.QColor() import random i = random.randint(1, 15) color.setHsv((15 - i) * 16, 255, 191) painter.setPen(color)