Skip to content

Qtica is a Python library that offers a lightweight API built around native PySide6. It enables swift GUI prototyping utilizing contemporary declarative UI methods, all within Python.

License

Notifications You must be signed in to change notification settings

qtica-project/Qtica

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Qtica

A Fast Way to Done Your Idea!

v0.6.0

Qtica

Qtica is a Python library that offers a lightweight API built around native PySide6. It enables swift GUI prototyping utilizing contemporary declarative UI methods, all within Python.

Qtica is currently in active development and not yet ready for stable release.

Features

  • Lightweight API: Built around PySide6, Qtica offers a streamlined interface for GUI development.
  • Declarative UI Techniques: Facilitates the use of modern UI techniques directly within Python.
  • Swift Prototyping: Enables rapid GUI prototyping for efficient development.

Installation

You can install Qtica via pip:

pip install qtica

Usage

import os
import sys
from PySide6.QtGui import QColor
from PySide6.QtCore import QSize, Qt
from Qtica.services import randomColor, colorToHex
from Qtica.widgets import MainWindow, Label, Application
from Qtica import BehaviorDec, Api


class Window(BehaviorDec):
    def get_text_color(self, color: QColor) -> QColor:
        luma = ((0.299 * color.red()) + (0.587 * color.green()) + (0.114 * color.blue())) / 255
        return QColor(0, 0, 0) if luma > 0.5 else QColor(255, 255, 255)

    def update_background(self):
        bg_color = randomColor()
        fg_color = self.get_text_color(bg_color)

        Api.fetch("window").qss.update({"background-color": bg_color.name()})
        Api.fetch("label").qss.update({"color": fg_color.name()})

    def __init__(self):
        return MainWindow(
            uid="window",
            windowTitle="Welcome Qtica!",
            methods = [
                ("resize", QSize(400, 200))
            ],
            events = [
                ("mousePress", lambda _: self.update_background())
            ],
            home=Label(
                uid="label",
                setText=f"Hello {os.environ.get('USER', '')}, Welcome to Qtica.<br>Click me!",
                setTextFormat=Qt.TextFormat.RichText,
                setAlignment=Qt.AlignmentFlag.AlignCenter,
                qss={"font-size": "24px"}
            ),
            qss={"background-color": colorToHex(randomColor())},
        )

app = Application(sys.argv)
window = Window()
window.show()
sys.exit(app.exec())

Documentation

For more information and detailed usage examples, refer to the documentation.

License

This project is licensed under the GPL3 License.

NOTE

Welcome to Qtica!

Thank you for choosing Qtica! Please be aware that this library is continuously evolving and is not yet considered stable as it's actively under development. We encourage you to use it for experimentation and kindly ask for your feedback, bug reports, suggestions, or improvements that align with your preferences. Your input is invaluable! 😊

Thank you for being a part of Qtica's development journey!

About

Qtica is a Python library that offers a lightweight API built around native PySide6. It enables swift GUI prototyping utilizing contemporary declarative UI methods, all within Python.

Topics

Resources

License

Stars

Watchers

Forks

Languages