Skip to main content

Castella is a pure Python cross-platform UI framework

Project description

Castella

Castella is a pure Python cross-platform UI framework.

Documentation Site Examples

Goals

The primary final goal of Castella is to provide features for Python programmers easy to create a GUI application for several OS platforms and web browsers in a single most same code as possible as. The second goal is to provide a UI framework that Python programmers can easily understand, modify, and extend as needed. (Stated on May 25, 2022: This goal is the final goal. Currently this framework is in the super early stage, so this goal is far away. I hope to get much closer to the goal in a few months or a year by improving the implementation or documentation a little bit every day as much as possible.)

Features

  • The core part as a UI framework of Castella is written in only Python. It's not a wrapper for existing something written in other programing languages.
  • Castella allows human to define UI declaratively in Python.
  • Castella provides hot-reloading or hot-restarting on development.
  • Dark mode is supported. If the runtime environment is in dark mode, Castella app's UI appearance will automatically be styled in dark mode.
  • Castella utilizes GPU via dependent libraries.

Dependencies

  • For desktop platforms, Castella is standing on existing excellent python bindings for window management library (GLFW or SDL2) and 2D graphics library (Skia).
  • For web browsers, Castella is standing on awesome Pyodide/PyScript and CanvasKit (Wasm version of Skia).

Installation

https://i2y.github.io/castella/getting-started/

An example of code using Castella

from castella import App, Button, Column, Component, Row, State, Text
from castella.frame import Frame


class Counter(Component):
    def __init__(self):
        super().__init__()
        self._count = State(0)

    def view(self):
        return Column(
            Text(self._count),
            Row(
                Button("Up", font_size=50).on_click(self.up),
                Button("Down", font_size=50).on_click(self.down),
            ),
        )

    def up(self, _):
        self._count += 1

    def down(self, _):
        self._count -= 1


App(Frame("Counter", 800, 600), Counter()).run()

https://user-images.githubusercontent.com/6240399/171010621-8c0068d2-eb90-4332-8a1b-115291053d42.mp4

You can see some other examples in examples directory.

Supported Platforms

Currently, Castella theoretically should support not-too-old versions of the following platforms.

  • Windows 10/11
  • Mac OS X
  • Linux
  • Web browsers

License

MIT License

Copyright (c) 2022 Yasushi Itoh

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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

castella-0.1.13.tar.gz (4.8 MB view details)

Uploaded Source

Built Distribution

castella-0.1.13-py3-none-any.whl (46.3 kB view details)

Uploaded Python 3

File details

Details for the file castella-0.1.13.tar.gz.

File metadata

  • Download URL: castella-0.1.13.tar.gz
  • Upload date:
  • Size: 4.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for castella-0.1.13.tar.gz
Algorithm Hash digest
SHA256 2a5674346ea8afa684db580eb38a865f971192f7d75364058c1f99c3fc9d45c1
MD5 118268f9e5ea0836771525f15f78c954
BLAKE2b-256 89ad81a703222dca8e65c16e802d180babe8ef780fe34b0af92082c91060ef8d

See more details on using hashes here.

File details

Details for the file castella-0.1.13-py3-none-any.whl.

File metadata

  • Download URL: castella-0.1.13-py3-none-any.whl
  • Upload date:
  • Size: 46.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for castella-0.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 6faf1630a9cb51210b9ea6056c062ebea047025c779676c0c1ef6760affef252
MD5 2d6ce72657f25453162f2f92daaaa8ea
BLAKE2b-256 1e31152712cd6d68c1aaad7e2ef17b82a867e3953bb70262cdb85a8a40e8743d

See more details on using hashes here.

Supported by

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