0

我想用 Python 制作一个笔压查看器。它在那个窗口中工作:

在此处输入图像描述

但是当我在 Photoshop 或其他软件中绘图时它不起作用。

当我在其他窗口中绘图时,如何使其工作?

import os, time, sys, subprocess
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *


class PressureBar(QWidget):
    def __init__(self, parent=None):
        super().__init__()
        self.pen_pressure = 0
        frame_rect = app.desktop().frameGeometry()
        self.progress = QProgressBar(self)
        self.resize(300, 30)
        self.progress.setGeometry(0, 0, 300, 25)
        self.progress.setMaximum(100)
        self.setWindowTitle("Pen Pressure Viewer")
        
    def tabletEvent(self, tabletEvent):
        self.pen_pressure = int(tabletEvent.pressure() * 100)

        if(tabletEvent.type() == QTabletEvent.TabletPress):
            self.penIsDown = True

        self.progress.setValue(self.pen_pressure)
        tabletEvent.accept()
        self.update()


app = QApplication(sys.argv)
myWindow = PressureBar()
myWindow.show()
app.exec()
4

0 回答 0