コード例 #1
0
    def screenshot_clicked(self):
        img = Screenshot.take_screenshot(constant.CLIPBOARD)
        if img is None:
            return

        self.img = img
        self.preview_label.setPixmap(
            QPixmap(img).scaled(self.preview_label.size(), Qt.KeepAspectRatio))
コード例 #2
0
    def shootScreen(self):
        img = Screenshot.take_screenshot(constant.CLIPBOARD)

        if img is not None:
            self.originalPixmap = None
            self.originalPixmap = QPixmap(img)
            self.updateScreenshotLabel()

            byte_array = QtCore.QByteArray()
            buffer = QtCore.QBuffer(byte_array)
            buffer.open(QtCore.QIODevice.WriteOnly)
            self.originalPixmap.save(buffer, 'PNG')
            self.encoded_pic = buffer.data().toBase64()
コード例 #3
0
    def screenshot_clicked(self):
        self.hide()
        img = Screenshot.take_screenshot(constant.CLIPBOARD)
        self.show()
        if img is None:
            return

        if self.sender() == self.screenshot_button:
            self.img = img  # type: QImage
            self.preview_label.setPixmap(QPixmap(img).scaled(self.preview_label.size(), Qt.KeepAspectRatio))
        elif self.sender() == self.screenshot_button_1:
            self.img_1 = img
            self.preview_label_1.setPixmap(QPixmap(img).scaled(self.preview_label_1.size(), Qt.KeepAspectRatio))
        elif self.sender() == self.screenshot_button_2:
            self.img_2 = img
            self.preview_label_2.setPixmap(QPixmap(img).scaled(self.preview_label_2.size(), Qt.KeepAspectRatio))
コード例 #4
0
 def TakeScreenShot(self):
     self.showMinimized()
     Screenshot.take_screenshot(constant.SAVE_TO_FILE)
     self.showNormal()
コード例 #5
0
import sys

from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QApplication, QLabel
from pyqt_screenshot.screenshot import Screenshot, constant

if __name__ == "__main__":
    QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    qtApp = QApplication(sys.argv)

    main_window = QLabel()
    img = Screenshot.take_screenshot(constant.CLIPBOARD)
    main_window.show()
    if img is not None:
        main_window.setPixmap(QPixmap(img))
    qtApp.exec()
コード例 #6
0
ファイル: demo.py プロジェクト: TianD/QuantStockSun
import sys
import time

from PySide2.QtCore import Qt
from PySide2.QtGui import QPixmap, QGuiApplication
from PySide2.QtWidgets import QApplication, QLabel
from pyqt_screenshot.screenshot import Screenshot, constant

if __name__ == "__main__":
    QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    qtApp = QApplication(sys.argv)

    # main_window = QLabel()
    # img = Screenshot.take_screenshot(constant.CLIPBOARD)
    pos = Screenshot.take_screenshot_pos(constant.CLIPBOARD)
    print(pos)
    for i in range(10):
        screen = QGuiApplication.screens()[0]
        screenPixel = screen.grabWindow(0)
        img = screenPixel.copy(pos)
        print(img)
        img.save('e:/abc_%03d.jpg' % i)
        time.sleep(10)
    # main_window.show()
    # if img is not None:
    #     main_window.setPixmap(QPixmap(img))
    qtApp.exec_()
コード例 #7
0
import sys

from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication
from pyqt_screenshot.screenshot import Screenshot, constant

if __name__ == "__main__":
    QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)

    qtApp = QApplication(sys.argv)
    window = Screenshot(constant.CLIPBOARD | constant.TEXT | constant.RECT | constant.ARROW | constant.FREEPEN
                        | constant.LINE | constant.ELLIPSE | constant.SAVE_TO_FILE)
    window.show()
    qtApp.exec()