No project description provided
Project description
pywidgets-ext
This is a custom widget module for PySide6
that makes it easy to manage and use during development.
Installation
Install using pip:
pip install pywidgets-ext
Install using poetry (recommended):
poetry add pywidgets-ext
Usage
from pywidgets_ext import *
Modules
PyFigureCanvas
PyFigureCanvas
is a custom widget inheriting from FigureCanvasQTAgg
. It's designed to display matplotlib charts. A unique feature is its magnified preview when the mouse hovers over it, which hides when the mouse leaves. The magnified view adjusts according to the screen size and mouse position. Additionally, PyFigureCanvas
offers methods to get chart dimensions, calculate data ratio, and adjust graphics view size on resize.
To see it in action:
python -m pywidgets_ext.PyFigureCanvas
Sample code:
import matplotlib.pyplot as plt
from PySide6.QtWidgets import QMainWindow, QApplication
from pywidgets_ext import PyFigureCanvas
class MainWindow(QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
fig, ax = self.create_sample_plot()
self.canvas = PyFigureCanvas(fig)
self.setup_main_window()
def create_sample_plot(self):
fig, ax = plt.subplots(figsize=(5, 5))
ax.plot([0, 1, 2, 3, 4], [0, 1, 4, 9, 16], label="y = x^2")
ax.set_title("Sample Plot")
ax.set_xlabel("x")
ax.set_ylabel("y")
ax.legend()
return fig, ax
def setup_main_window(self):
self.setCentralWidget(self.canvas)
self.setWindowTitle("PyFigureCanvas Demo")
self.resize(600, 600)
if __name__ == "__main__":
app = QApplication([])
window = MainWindow()
window.show()
app.exec()
PyGraphicsView
PyGraphicsView
is a view class inheriting from QGraphicsView
. It lets users click and drag in the scene to draw and adjust resizable rectangular regions (ResizableRect
). It offers specific drawing and optimization options for better performance and visuals. Users can select rectangles and delete them using the Delete
key. Also, it auto-adjusts rectangles when the scene size changes.
To see it in action:
python -m pywidgets_ext.PyGraphicsView
Sample code:
from PySide6.QtCore import Qt, QRectF, QPointF
from PySide6.QtWidgets import QApplication, QMainWindow
from pywidgets_ext import PyGraphicsView
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.view = PyGraphicsView()
self.view.setSceneRect(0, 0, 500, 500)
self.setCentralWidget(self.view)
self.setGeometry(100, 100, 800, 600)
self.setWindowTitle("PyGraphicsView Example")
if __name__ == "__main__":
app = QApplication([])
window = MainWindow()
window.show()
app.exec()
Contributions
Contributions of any kind are welcome! Make sure to read the Contribution Guide first.
License
This project is under the MIT License.
Author
- Leo - Github
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
Built Distribution
Hashes for pywidgets_ext-0.1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b183ccb7c003ff5353df6bc69de66e5ccca6d10cb6114a36990dd798892f0e3 |
|
MD5 | 73abcc19158e4a2c2d29f6c47fcb97c0 |
|
BLAKE2b-256 | bcdddcfbf64df7070dfec4de9ccdc1982b49c544dffcbf3fe299e6e5fdde7b4c |