Skip to main content

PyQt5/PySide2 widget for displaying images

Project description

QImageWidget Documentation

QImageWidget is a Python library that provides a widget for displaying images in a PyQt5 GUI. The library allows you to easily load images and scale them to fit the widget.



Installation

You can install QImageWidget by cloning the GitHub repository:

git clone https://github.com/RedEnder666/QImageWidget

Methods

Method Arguments Description
init(self, parent, img='') parent: QWidget, img: str Initializes a new QImageWidget object with an optional image.
setImage(self, img) img: str Sets the image for the QImageWidget.
setScale(self, size, aspectRatioMode=Qt.IgnoreAspectRatio) size: tuple, aspectRatioMode: Qt.AspectRatioMode Scales the image to the specified size with the specified aspect ratio mode.

# Usage Here is an example of how to use QImageWidget:
import sys
from PyQt5.QtCore import Qt, QSize
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QPushButton
from QImageWidget.QImageWidget import QImageWidget

class ImageWidget(QWidget):
    def __init__(self):
        super().__init__()

        # Create a QImageWidget object
        self.imageWidget = QImageWidget(self)

        # Set the image
        self.imageWidget.setImage('example.jpg')

        # Set the scaling
        self.imageWidget.setScale((400, 400), Qt.KeepAspectRatio)

        # Create a button to update the image
        self.btnUpdate = QPushButton('Update', self)
        self.btnUpdate.clicked.connect(self.updateImage)

        # Create a vertical layout and add the widgets to it
        layout = QVBoxLayout(self)
        layout.addWidget(self.imageWidget)
        layout.addWidget(self.btnUpdate)

    def updateImage(self):
        # Update the image
        self.imageWidget.setImage('example2.jpg')

if __name__ == '__main__':
    app = QApplication(sys.argv)

    # Create an ImageWidget object
    widget = ImageWidget()
    widget.show()

    sys.exit(app.exec_())

This example creates a QImageWidget object, sets an image, sets scaling, and adds the widget to a vertical layout along with a button to update the image. When the button is clicked, the updateImage method is called, which changes the image to a different one. The code also creates a QApplication object and displays the widget on the screen.

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

qimagewidget-1.0.5.tar.gz (2.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qimagewidget-1.0.5-py3-none-any.whl (2.2 kB view details)

Uploaded Python 3

File details

Details for the file qimagewidget-1.0.5.tar.gz.

File metadata

  • Download URL: qimagewidget-1.0.5.tar.gz
  • Upload date:
  • Size: 2.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.4

File hashes

Hashes for qimagewidget-1.0.5.tar.gz
Algorithm Hash digest
SHA256 c098267819b0896ac118ad2a42883926fa9be3307e47b8339e1d545ed00f6d59
MD5 7f421e7a97af123dac1fd8be71f66d3b
BLAKE2b-256 56b136df5a1b0e08c0bcffdc35b8926f44e24939224a8369b83be4421893ef63

See more details on using hashes here.

File details

Details for the file qimagewidget-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: qimagewidget-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 2.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.4

File hashes

Hashes for qimagewidget-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7e0dd75ff44767bfdb07f43942577001ace1141b844527f5885638ff1af80d13
MD5 4dc2066c3617b0f23da5592920d073f6
BLAKE2b-256 6c617fa42b9dcc062a9d7e5f75f424003c73c1d72f8db3d4e7bcbb821e5a6e4f

See more details on using hashes here.

Supported by

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