def start_update(self, secs):
     print "Starting update timer for %d seconds" % secs
     try:
         self._updateTimer.stop()
     except:
         pass
     self._updateTimer = QtCore.QTimer()
     self._updateTimer.timeout.connect(self.manual_update)
     self._updateTimer.start(secs * 1000)
Exemplo n.º 2
0
    def __init__(self, parent=None):
        super(self.__class__, self).__init__(parent=parent)
        self.setWindowTitle('Making Screenshot')

        self.setWindowFlags(QtCore.Qt.FramelessWindowHint
                            | QtCore.Qt.WindowStaysOnTopHint)
        self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
        # self.setWindowOpacity(0.5)

        self.setWindowModality(QtCore.Qt.ApplicationModal)

        # self.setSizeGripEnabled(True)

        mouse_pos = Qt4Gui.QCursor.pos()
        self.setGeometry(mouse_pos.x() - 16, mouse_pos.y() - 16, 32, 32)

        # self.resize(150, 150)
        # self.move()

        self.label_lay = QtGui.QVBoxLayout()
        self.setLayout(self.label_lay)
        self.screenshot_pixmap = None

        self.label_lay.setContentsMargins(0, 0, 0, 0)
        self.label_lay.setSpacing(0)

        self.bg_wd = QtGui.QLabel()
        self.bg_wd.setStyleSheet(
            'QLabel {padding: 0px;border: 2px dashed grey; background-color: rgba(0,0,0,25);}'
        )
        self.label_lay.addWidget(self.bg_wd)
        self.bg_wd.setMouseTracking(True)

        self.button_lay = QtGui.QHBoxLayout(self.bg_wd)
        self.button_lay.setContentsMargins(0, 0, 0, 0)
        self.button_lay.setSpacing(0)

        self.pb = QtGui.QToolButton()
        self.pb.setText('Take Screenshot')
        self.pb.setAutoRaise(True)
        # self.button_lay.addWidget(self.pb)

        self.pb.clicked.connect(self.ru)

        self.__dragging = False
        self.__resizing = False
        self.__offset_pos = None

        self.single_click_timer = QtCore.QTimer()
        self.single_click_timer.setInterval(1000)
        self.single_click_timer.timeout.connect(self.ts)

        self.create_ui()