Beispiel #1
0
def setbg(widget, filename):
    widget.setAutoFillBackground(True)
    palette = QtGui.QPalette()
    pixmap = QtGui.QPixmap(filename)
    pixmap = pixmap.scaled(widget.size())
    palette.setBrush(QtGui.QPalette.Background, QtGui.QBrush(pixmap))
    widget.setPalette(palette)
Beispiel #2
0
    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.