Esempio n. 1
0
 def setPaintAttribute(self, attribute, on=True):
     if bool(self.__data.paintAttributes & attribute) == on:
         return
     if on:
         self.__data.paintAttributes |= attribute
     else:
         self.__data.paintAttributes &= ~attribute
     if attribute == self.BackingStore:
         if on:
             if self.__data.backingStore is None:
                 self.__data.backingStore = QPixmap()
             if self.isVisible():
                 if QT_VERSION >= 0x050000:
                     self.__data.backingStore = self.grab(self.rect())
                 else:
                     if PYQT5:
                         pm = QPixmap.grabWidget(self, self.rect())
                     else:
                         pm = self.grab(self.rect())
                     self.__data.backingStore = pm
         else:
             self.__data.backingStore = None
     elif attribute == self.Opaque:
         if on:
             self.setAttribute(Qt.WA_OpaquePaintEvent, True)
     elif attribute in (self.HackStyledBackground, self.ImmediatePaint):
         pass
Esempio n. 2
0
 def setPaintAttribute(self, attribute, on=True):
     if bool(self.__data.paintAttributes & attribute) == on:
         return
     if on:
         self.__data.paintAttributes |= attribute
     else:
         self.__data.paintAttributes &= ~attribute
     if attribute == self.BackingStore:
         if on:
             if self.__data.backingStore is None:
                 self.__data.backingStore = QPixmap()
             if self.isVisible():
                 if QT_VERSION >= 0x050000:
                     self.__data.backingStore = self.grab(self.rect())
                 else:
                     if PYQT5:
                         pm = QPixmap.grabWidget(self, self.rect())
                     else:
                         pm = self.grab(self.rect())
                     self.__data.backingStore = pm
         else:
             self.__data.backingStore = None
     elif attribute == self.Opaque:
         if on:
             self.setAttribute(Qt.WA_OpaquePaintEvent, True)
     elif attribute in (self.HackStyledBackground, self.ImmediatePaint):
         pass
Esempio n. 3
0
 def mousePressEvent(self, event):
     if event.button() == Qt.LeftButton:
         if PYQT5:
             pm = self.grab()
         else:
             pm = QPixmap.grabWidget(self)
         color = QColor()
         color.setRgb(pm.toImage().pixel(event.x(), event.y()))
         self.colorSelected.emit(color)
         event.accept()
Esempio n. 4
0
 def mousePressEvent(self, event):
     if event.button() == Qt.LeftButton:
         if PYQT5:
             pm = self.grab()
         else:
             pm = QPixmap.grabWidget(self)
         color = QColor()
         color.setRgb(pm.toImage().pixel(event.x(), event.y()))
         self.SIG_COLOR_SELECTED.emit(color)
         event.accept()
Esempio n. 5
0
    def setPaintAttribute(self, attribute, on=True):
        """
        Changing the paint attributes

        Paint attributes:
        
            * `QwtPlotCanvas.BackingStore`
            * `QwtPlotCanvas.Opaque`
            * `QwtPlotCanvas.HackStyledBackground`
            * `QwtPlotCanvas.ImmediatePaint`
        
        :param int attribute: Paint attribute
        :param bool on: On/Off
        
        .. seealso::
        
            :py:meth:`testPaintAttribute()`, :py:meth:`backingStore()`
        """
        if bool(self.__data.paintAttributes & attribute) == on:
            return
        if on:
            self.__data.paintAttributes |= attribute
        else:
            self.__data.paintAttributes &= ~attribute
        if attribute == self.BackingStore:
            if on:
                if self.__data.backingStore is None:
                    self.__data.backingStore = QPixmap()
                if self.isVisible():
                    if QT_VERSION >= 0x050000:
                        self.__data.backingStore = self.grab(self.rect())
                    else:
                        if PYQT5:
                            pm = QPixmap.grabWidget(self, self.rect())
                        else:
                            pm = self.grab(self.rect())
                        self.__data.backingStore = pm
            else:
                self.__data.backingStore = None
        elif attribute == self.Opaque:
            if on:
                self.setAttribute(Qt.WA_OpaquePaintEvent, True)
        elif attribute in (self.HackStyledBackground, self.ImmediatePaint):
            pass
Esempio n. 6
0
    def setPaintAttribute(self, attribute, on=True):
        """
        Changing the paint attributes

        Paint attributes:
        
            * `QwtPlotCanvas.BackingStore`
            * `QwtPlotCanvas.Opaque`
            * `QwtPlotCanvas.HackStyledBackground`
            * `QwtPlotCanvas.ImmediatePaint`
        
        :param int attribute: Paint attribute
        :param bool on: On/Off
        
        .. seealso::
        
            :py:meth:`testPaintAttribute()`, :py:meth:`backingStore()`
        """
        if bool(self.__data.paintAttributes & attribute) == on:
            return
        if on:
            self.__data.paintAttributes |= attribute
        else:
            self.__data.paintAttributes &= ~attribute
        if attribute == self.BackingStore:
            if on:
                if self.__data.backingStore is None:
                    self.__data.backingStore = QPixmap()
                if self.isVisible():
                    if QT_VERSION >= 0x050000:
                        self.__data.backingStore = self.grab(self.rect())
                    else:
                        if PYQT5:
                            pm = QPixmap.grabWidget(self, self.rect())
                        else:
                            pm = self.grab(self.rect())
                        self.__data.backingStore = pm
            else:
                self.__data.backingStore = None
        elif attribute == self.Opaque:
            if on:
                self.setAttribute(Qt.WA_OpaquePaintEvent, True)
        elif attribute in (self.HackStyledBackground, self.ImmediatePaint):
            pass
Esempio n. 7
0
 def _save_display(self, chartplot):
     self._png_number += 1
     # put together filename components
     name_components = []
     if self._grab_name:
         name_components.append(self._grab_name)
     if self._menu.isVellsControlVisible():
         name_components.append(str(self._menu.vells_component))
     if self._menu.isComplexControlVisible():
         name_components.append(
             str(self._menu.ComplexComponentLabels[
                 self._menu.complex_component]))
     if len(self._ChartPlot) > 1:
         name_components.append(chartplot.dataLabel())
     name_components.append(str(self._png_number))
     save_file = "_".join(name_components).replace(' ', '_') + ".png"
     try:
         pm = QPixmap.grabWidget(chartplot)
         pm.save(save_file, "PNG")
         return save_file, None
     except:
         traceback.print_exc()
         print('failed to grab or save pixmap')
         return save_file, True