Giter Site home page Giter Site logo

khanhlinhdang / qtica Goto Github PK

View Code? Open in Web Editor NEW

This project forked from qtica-project/qtica

0.0 0.0 0.0 2.72 MB

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: GNU General Public License v3.0

Python 100.00%

qtica's Introduction

Qtica

A Fast Way to Done Your Idea!

v0.4.2

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!

qtica's People

Contributors

omamkaz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.