Skip to main content

A expand about pyside6

Project description

英文版

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
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.1.tar.gz (3.0 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: pyside6_expand-1.0.1.tar.gz
  • Upload date:
  • Size: 3.0 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.1.tar.gz
Algorithm Hash digest
SHA256 4a62658f262c35103ff21deff8d675629156a9ff39e2a4327fbd5a4762b04076
MD5 a834cb54466633796985d92d25ef7088
BLAKE2b-256 de1fbe034797d49c3f88523a43faf1c3a9a1bc5590ce1760facb03a45841a09b

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