Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
A modern and fully customizable CAPTCHA library for PyQt and PySide.
This library was made to bring CAPTCHA support to PyQt desktop applications. While the measure is mostly used in web applications due to their ease of automation, desktop applications can also be automated using programs like AutoHotkey. This CAPTCHA widget is fully customizable from everything related to visuals to the difficulty of the tasks and helps protect your application from spam and abuse through automation.
All images have been sourced from public domain video material and are not subject to copyright restrictions.
pip install pyqtcaptcha
from PyQt6.QtWidgets import QMainWindow
from pyqtcaptcha import Captcha, CaptchaDifficulty
class Window(QMainWindow):
def __init__(self):
super().__init__(parent=None)
self.captcha = Captcha(self)
self.captcha.setDifficulty(CaptchaDifficulty.HARD)
self.captcha.setFixedSize(130, 40)
IMPORTANT:
Styling of the widget must not be done by setting the stylesheet manually as the widget calculates the stylesheet itself and overrides it. Use the provided methods such assetBackgroundColor()
instead.
captcha.setDifficulty(CaptchaDifficulty.HARD)
On easy difficulty the user will have to complete image selection tasks (i.e. "Select all images containing cars"). On hard difficulty the user will have to select image squares (i.e. "Select all squares containing traffic lights"). Medium difficulty alternates between these two options randomly.
captcha.isPassed()
captcha.reset()
captcha.setText('Text')
captcha.setButtonForegroundColor(QColor(255, 0, 0))
captcha.setButtonBackgroundColor(QColor(0, 255, 0))
captcha.setButtonBorderColor(QColor(0, 0, 255))
captcha.setButtonBorderWidth(1)
captcha.setButtonBorderRadius(5)
captcha.setCheckboxColor(QColor(255, 255, 0))
captcha.setCheckboxWidth(2)
The checkbox width is also used for the width of the checkmark.
captcha.setCheckmarkColor(QColor(0, 255, 255))
captcha.setCaptchaForegroundColor(QColor(255, 255, 255))
The foreground color (white by default) is used for text elements like the captcha prompt and submit button text as well as for the checkmark on selected images.
captcha.setCaptchaBackgroundColor(QColor(255, 0, 255))
The background color (white by default) is used for the background of the popup window.
captcha.setCaptchaBorderColor(QColor(100, 255, 0))
captcha.setCaptchaBorderRadius(10)
captcha.setCaptchaPrimaryColor(QColor(0, 100, 255))
The primary color (green by default) is used for the background of the captcha prompt and the background of the submit button.
captcha.setCaptchaPrimaryColorHovered(QColor(255, 100, 0))
The primary hovered color (light-green by default) is used for the hovered background of the submit button.
captcha.setCaptchaSecondaryColor(QColor(255, 255, 100))
The secondary color (gray by default) is used for elements like the refresh button, visual button, audio button and play button.
captcha.setCaptchaSecondaryColorHovered(QColor(0, 255, 50))
The secondary hovered color (dark-gray by default) is used as the hover color for elements like the refresh button, visual button, audio button and play button.
captcha.started.connect(self.some_function)
captcha.aborted.connect(self.some_function)
captcha.passed.connect(self.some_function)
captcha.failed.connect(self.some_function)
The
started
signal is emitted every time the popup window gets opened, while theaborted
signal is emitted every time the popup window gets closed without submitting an answer. When the submit button is pressed either thepassed
signal or thefailed
signal is emitted depending on the correctness of the answer.
All available methods:
Method | Description |
---|---|
text(self) | Get the current button text |
setText(self, text: str) | Set the button text |
getButtonForegroundColor(self) | Get the current button foreground color |
setButtonForegroundColor(self, color: QColor) | Set the button foreground color |
getButtonBackgroundColor(self) | Get the current button background color |
setButtonBackgroundColor(self, color: QColor) | Set the button background color |
getButtonBorderColor(self) | Get the current button border color |
setButtonBorderColor(self, color: QColor) | Set the button border color |
getButtonBorderWidth(self) | Get the current button border width |
setButtonBorderWidth(self, width: int) | Set the button border width |
getButtonBorderRadius(self) | Get the current button border radius |
setButtonBorderRadius(self, radius: int) | Set the button border radius |
getCheckboxColor(self) | Get the current checkbox color |
setCheckboxColor(self, color: QColor) | Set the checkbox color |
getCheckboxWidth(self) | Get the current checkbox width |
setCheckboxWidth(self, width: int) | Set the checkbox width |
getCheckmarkColor(self) | Get the current checkmark color |
setCheckmarkColor(self, color: QColor) | Set the checkmark color |
getCaptchaForegroundColor(self) | Get the current captcha foreground color |
setCaptchaForegroundColor(self, color: QColor) | Set the captcha foreground color |
getCaptchaBackgroundColor(self) | Get the current captcha background color |
setCaptchaBackgroundColor(self, color: QColor) | Set the captcha background color |
getCaptchaBorderColor(self) | Get the current captcha border color |
setCaptchaBorderColor(self, color: QColor) | Set the captcha border color |
getCaptchaBorderRadius(self) | Get the current captcha border radius |
setCaptchaBorderRadius(self, radius: int) | Set the captcha border radius |
getCaptchaPrimaryColor(self) | Get the current captcha primary color |
setCaptchaPrimaryColor(self, color: QColor) | Set the captcha primary color |
getCaptchaPrimaryColorHovered(self) | Get the current captcha primary hovered color |
setCaptchaPrimaryColorHovered(self, color: QColor) | Set the captcha primary hovered color |
getCaptchaSecondaryColor(self) | Get the current captcha secondary color |
setCaptchaSecondaryColor(self, color: QColor) | Set the captcha secondary color |
getCaptchaSecondaryColorHovered(self) | Get the current captcha secondary hovered color |
setCaptchaSecondaryColorHovered(self, color: QColor) | Set the captcha secondary hovered color |
getDifficulty(self) | Get the current captcha difficulty |
setDifficulty(self, difficulty: CaptchaDifficulty) | Set the captcha difficulty |
isPassed(self) | Has the captcha been completed? |
setPassed(self, passed: bool) | Set the completion status of the captcha |
reset(self) | Reset the captcha |
getPopup(self) | Get the current captcha popup |
https://github.com/user-attachments/assets/4a9245ea-3cee-40fd-9457-123a4dc0c58a
This software is licensed under the MIT license.
FAQs
A modern and fully customizable CAPTCHA library for PyQt and PySide
We found that pyqtcaptcha demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.