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

Signals Arg:

  • arg for the instance of widget
  • such as widget.left_clicked.connect(lambda w:print(w))
  • w:<__main__.CustomWidget(0x1f691a60910) at 0x000001F6936C6280>

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) # or @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 item: print("Left button clicked"))
    widget.left_double_clicked.connect(lambda item: print("Left button double clicked"))
    widget.left_long_press.connect(lambda item: print("Left button long pressed"))
    widget.right_clicked.connect(lambda item: print("Right button clicked"))
    widget.right_double_clicked.connect(lambda item: print("Right button double clicked"))
    widget.right_long_press.connect(lambda item: 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.4.tar.gz (3.1 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: pyside6_expand-1.0.4.tar.gz
  • Upload date:
  • Size: 3.1 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.4.tar.gz
Algorithm Hash digest
SHA256 21bad36daba7b2b3d928df7e484e11b1550afaf50fb0d749396650c24e680377
MD5 1698fc8404a946c7bff47f711ba6870b
BLAKE2b-256 02584dd60a66d73883fd38fe2eb6b46fa6dd37e7ae4c2fa8335e0fe7bddac31c

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