Want to make pen pressure viewer with Python

384 Views Asked by At

I want to make a pen pressure viewer with Python. It's working in that window:

enter image description here

but it's not working when I'm drawing in Photoshop or just other software.

How can I make it work when I'm drawing in other windows?

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()
1

There are 1 best solutions below

1
Ulaş Önder On

Is it a Wacom tablet? In their official documents, they say, tablet sends the value only to the active window.