
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
A QPushButton with built-in loading animations for PyQt and PySide.
The widget functions exactly like PyQt's regular QPushButton
with the only exception being the way methods are connected to the clicked
event. Normally you would connect a method to the clicked
event by using the connect()
method. On this button you use the setAction()
method instead, passing a callable object as its parameter the same way you would do with the connect()
method. The method will then get executed in a QThread
, allowing the button to display a loading animation.
pip install pyqt-loading-button
import time
from PyQt6.QtGui import QColor
from PyQt6.QtWidgets import QMainWindow
from pyqt_loading_button import LoadingButton, AnimationType
class Window(QMainWindow):
def __init__(self):
super().__init__(parent=None)
# LoadingButton
self.button_1 = LoadingButton(self)
self.button_1.setText('Click me!')
self.button_1.setAnimationType(AnimationType.Circle)
self.button_1.setAnimationSpeed(2000)
self.button_1.setAnimationColor(QColor(0, 0, 0))
self.button_1.setAnimationWidth(15)
self.button_1.setAnimationStrokeWidth(3)
self.button_1.setAction(self.do_something)
def do_something(self):
time.sleep(5) # Simulate long task
loading_button.setText('Click me!')
def do_something():
time.sleep(5) # Simulate long task
loading_button.setAction(do_something)
loading_button.setAnimationType(AnimationType.Circle) # Circular animation
loading_button.setAnimationType(AnimationType.Dots) # Dotted animation
# 2000 means each loop of the animation takes 2000 ms to complete
loading_button.setAnimationSpeed(2000)
loading_button.setAnimationWidth(15) # Total width of the animation is 15 px
loading_button.setAnimationStrokeWidth(3) # Stroke width of the brush is 3 px
loading_button.setAnimationColor(QColor(0, 0, 0))
loading_button.isRunning()
All methods:
Method | Description |
---|---|
text(self) | Get the current button text |
setText(self, text: str) | Set the button text |
setAction(self, action: callable) | Set the action connected to the clicked event |
isRunning(self) | Get whether the action is currently being executed |
getAnimationType(self) | Get the current animation type |
setAnimationType(self, animation_type: AnimationType) | Set the animation type |
getAnimationSpeed(self) | Get the current animation speed (time it takes the animation to complete one loop in ms) |
setAnimationSpeed(self, speed: int) | Set the animation speed (time it takes the animation to complete one loop in ms) |
getAnimationWidth(self) | Get the current width of the animation |
setAnimationWidth(self, width: int) | Set the width of the animation |
getAnimationStrokeWidth(self) | Get the current width of the brush stroke |
setAnimationStrokeWidth(self, width: int) | Set the width of the brush stroke |
getAnimationColor(self) | Get the current animation color |
setAnimationColor(self, color: QColor) | Set the animation color |
This software is licensed under the MIT license.
FAQs
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
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.