Skip to main content

A expand about pyside6

Project description

English

PySide6-Expand Usage Guide

0. Installation

Install PySide6-Expand using pip:

pip install pyside6-expand

Then import the required module in your code:

from pyside6_expand.expand_signal import mouse_signal

1. Extension - Mouse Signals

Apply the @mouse_signal decorator to classes that inherit from QWidget to dynamically bind mouse event signals at runtime.

Supported Signals

  • left_clicked: Left button click
  • left_double_clicked: Left button double click
  • left_long_press: Left button long press
  • right_clicked: Right button click
  • right_double_clicked: Right button double click
  • right_long_press: Right button long press

These signals operate independently and do not interfere with each other.

Notes

  • The @mouse_signal decorator overrides the methods mouseDoubleClickEvent, mousePressEvent, and mouseReleaseEvent.
  • When handling mouse press events, mousePressEvent is called first, followed by the corresponding signal.
  • When handling mouse release events, mouseReleaseEvent is called first, followed by the logic of the respective signal.
  • Do not override mouseDoubleClickEvent again, otherwise the left_double_clicked and right_double_clicked signals will fail to work.

Example Code

from pyside6_expand.expand_signal import mouse_signal
from PySide6.QtWidgets import QWidget, QApplication

@mouse_signal(long_press_threshold=500)
class CustomWidget(QWidget):
    def __init__(self):
        super().__init__()

if __name__ == '__main__':
    app = QApplication([])
    widget = CustomWidget()
    
    # Connect signals to slots
    widget.left_clicked.connect(lambda: print("Left button clicked"))
    widget.left_double_clicked.connect(lambda: print("Left button double clicked"))
    widget.left_long_press.connect(lambda: print("Left button long pressed"))
    widget.right_clicked.connect(lambda: print("Right button clicked"))
    widget.right_double_clicked.connect(lambda: print("Right button double clicked"))
    widget.right_long_press.connect(lambda: print("Right button long pressed"))

    widget.show()
    app.exec()

Additional Features

This project is actively developing new features, so stay tuned for updates.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyside6_expand-1.0.3.tar.gz (2.9 kB view details)

Uploaded Source

File details

Details for the file pyside6_expand-1.0.3.tar.gz.

File metadata

  • Download URL: pyside6_expand-1.0.3.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.14

File hashes

Hashes for pyside6_expand-1.0.3.tar.gz
Algorithm Hash digest
SHA256 c85218762b06d616f427ddf806cb427aa9c819f9130c9b1d94e27cf3d0915261
MD5 c5ae885952d48b6a96c8e12e46672a2f
BLAKE2b-256 1f73b2ce42f73bbda75dd5d25284bf722c854d7821deaf1a565b1cb5ab706f35

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page