Skip to main content

PyGraphicUI enhances PyQt6 GUI development with simplified widget creation, intuitive layout management, dynamic time-based widgets, and an object-oriented approach to stylesheets, reducing boilerplate and improving code readability.

Project description

PyGraphicUI: Enhanced PyQt6 GUI Development

PyGraphicUI is a Python library built on top of PyQt6 that streamlines the creation of graphical user interfaces. It provides a more intuitive and Pythonic approach to designing and managing PyQt6 widgets and layouts, simplifying complex tasks and reducing boilerplate code.

Key Features:

  • Simplified Widget Initialization: Create PyQt6 widgets with ease using dedicated initialization classes like WidgetInit, SpinBoxInit, LabelInit, and more. These classes provide a cleaner way to set widget properties during creation.
  • Enhanced Layout Management: Easily construct and manage complex layouts with PyVerticalLayout, PyHorizontalLayout, and GridLayout. Add, remove, and access layout items with convenient methods.
  • Dynamic Time-Based Widgets: Incorporate dynamic time display with PyTimer and PyStopWatch, offering customizable formatting and update intervals. Also includes a PyProgressWatcher for tracking progress with estimated time remaining.
  • Powerful Styling with StyleSheets: Create and apply custom stylesheets using a structured and object-oriented approach. BaseStyle, BaseStyleSheet, and specialized style classes for different widgets provide fine-grained control over appearance. Chain styles together for complex selectors.

Installation:

  • With pip:

    pip install PyGraphicUI
    
  • With git:

    pip install git+https://github.com/oddshellnick/PyGraphicUI.git
    

Example Usage:

from PyGraphicUI.PyObjects import PyWidgetWithVerticalLayout, WidgetWithLayoutInit, WidgetInit, LayoutInit, PyPushButton, PushButtonInit
from PyGraphicUI.PyStyleSheets import WidgetStyleSheet, WidgetStyle, Background, Brush, Color, RGB, PushButtonStyleSheet, PushButtonStyle, BorderRadius, BoxLengths, Length, PX, TextColor
from PyGraphicUI.Attributes import ObjectSize, PyFont
from PyQt6.QtWidgets import QApplication, QMainWindow
from PyGraphicUI.Attributes import LinearLayoutItem
from PyQt6.QtCore import Qt, QMetaObject
import sys


class MainProjectWindow(QMainWindow):
    def __init__(self):
        super().__init__()

        self.main_window = PyWidgetWithVerticalLayout(
                widget_with_layout_init=WidgetWithLayoutInit(
                        widget_init=WidgetInit(
                                parent=self,
                                minimum_size=ObjectSize(800, 600),
                                style_sheet=WidgetStyleSheet(
                                        WidgetStyle(
                                                background=Background(Brush(Color(RGB(45, 45, 45))))
                                        )
                                ).style_sheet
                        ),
                        layout_init=LayoutInit(
                                alignment=Qt.AlignmentFlag.AlignCenter,
                                contents_margins=(10, 10, 10, 10),
                                spacing=10
                        )
                )
        )

        self.button = PyPushButton(
                button_init=PushButtonInit(
                        parent=self.main_window,
                        style_sheet=PushButtonStyleSheet(
                                PushButtonStyle(
                                        background=Background(Brush(Color(RGB(90, 90, 90)))),
                                        border_radius=BorderRadius(BoxLengths(Length(PX(10)))),
                                        text_color=TextColor(Brush(Color(RGB(230, 230, 230))))
                                )
                        ).style_sheet,
                        fixed_size=ObjectSize(width=100, height=50),
                        font=PyFont(size=32, size_type="point")
                ),
                instance="Click"
        )
        self.main_window.add_instance(LinearLayoutItem(self.button))

        self.setCentralWidget(self.main_window)
        QMetaObject.connectSlotsByName(self)
        self.show()

        
def run_program():
    app = QApplication(sys.argv)

    main_window = MainProjectWindow()

    sys.exit(app.exec())

run_program()

Future Notes

PyGraphicUI is actively maintained and will continue to be updated with new widgets, styles, and features. We encourage contributions and welcome suggestions for improvements. Don't hesitate to propose new additions or report any issues you encounter.

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

pygraphicui-1.5.8.tar.gz (74.6 kB view details)

Uploaded Source

Built Distribution

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

PyGraphicUI-1.5.8-py3-none-any.whl (121.4 kB view details)

Uploaded Python 3

File details

Details for the file pygraphicui-1.5.8.tar.gz.

File metadata

  • Download URL: pygraphicui-1.5.8.tar.gz
  • Upload date:
  • Size: 74.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for pygraphicui-1.5.8.tar.gz
Algorithm Hash digest
SHA256 0eb22970760d54d0b2b67f1b1fe0c0f0efe7f8451c331cedffaff5b65e95f4fb
MD5 910c23471e374a8af69ae3b7ad199377
BLAKE2b-256 80c12ee7329821742f715711e87d21eae7708cfdf1c4d123daebf1feec0adb20

See more details on using hashes here.

File details

Details for the file PyGraphicUI-1.5.8-py3-none-any.whl.

File metadata

  • Download URL: PyGraphicUI-1.5.8-py3-none-any.whl
  • Upload date:
  • Size: 121.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for PyGraphicUI-1.5.8-py3-none-any.whl
Algorithm Hash digest
SHA256 23bf7f3483951010c34f66fbf9132c6c88ea8385162629de18602bc762b28c8a
MD5 1e38928c4d6fbaee1e46d665641ba33a
BLAKE2b-256 fae641eca6168b06cf9afc72fb7c7f9007b5d151875a74a76eb0a673cec0bb2a

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