I am currently working on a "snipping tool" app. During the snipping process, the entire screen should become a translucent white, meanwhile the snipped area should be transparent. So far, I have managed to make the whole screen a translucent white, but I am not sure how to make the snipped area transparent. How can I achieve this?
Here is the code I have so far, it produces a translucent window
from PyQt5 import QtWidgets, QtGui, QtCore
from PyQt5.QtWidgets import QApplication, QMainWindow, QDesktopWidget, QSizeGrip
import cv2
import sys
import time
import numpy as np
class Window(QMainWindow):
def __init__(self):
super().__init__()
self.title = "Frameless"
self.xpos = 0
self.ypos = 0
self.width = QDesktopWidget().availableGeometry().bottomRight().x()
self.height = QDesktopWidget().availableGeometry().bottomRight().y()
self.initUI()
def initUI(self):
self.setWindowTitle(self.title)
self.setGeometry(self.xpos, self.ypos, self.width, self.height)
self.setWindowOpacity(0.5)
flags = QtCore.Qt.WindowFlags(
QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint)
self.setWindowFlags(flags)
self.show()
def window():
app = QApplication(sys.argv)
win = Window()
sys.exit(app.exec_())
window()