Skip to main content

Applepy is a UI library inspired by Swift UI that leverages AppKit and UIKit (soon) to create native MacOS, iOS and iPadOS user interfaces in the Python programming language with a declarative syntax.

Project description

applepy

Applepy is a UI library inspired by Swift UI that leverages AppKit and UIKit to create native MacOS, iOS and iPadOS user interfaces in the Python programming language with a declarative syntax.

This project is at proof of concept stage and is not feature complete. Please do not use it in production.

Dependencies

Installation

The latest version is available for installation in PyPI:

pip install applepy-ui

Usage

class Sample(App):
    def body(self) -> Scene:
        with Window(title='Applepy example', size=Size(640, 100)) as w:
            with VerticalStack():
                with HorizontalStack():
                    Label(text='Hello')
                    Label(text='World')
                
            return w.center()
Sample().run()

image

It also works on mobile:

class MobileSample(App):
    def body(self):
        with SimpleScreen() as s:
            with HorizontalStack():
                with VerticalStack():
                    Label(text='Hello World')
            return s

def main():
    sys.exit(MobileSample().run())

Events can be handled synchronously and asynchronously in the same context:

class AsyncSample(App):
    def clicked(self) -> None:
        time.sleep(2)
        Alert.show_info(informative_text='Hello', message_text='Synchronous World')

    async def clicked_async(self) -> None:
        await asyncio.sleep(2)
        Alert.show_info(informative_text='Hello', message_text='Asynchronous World')

    def body(self) -> Scene:
        with Window(title='Applepy async example', size=Size(640,480)) as w:
            with HorizontalStack():
                with VerticalStack():
                    Button(title='Sync action', action=self.clicked)
                    Button(title='Async action', action=self.clicked_async)
                return w.center()

AsyncSample().run_async()

For a more complete example, please check example.py

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

applepy-ui-0.0.5.tar.gz (38.1 kB view hashes)

Uploaded Source

Built Distribution

applepy_ui-0.0.5-py3-none-any.whl (49.9 kB view hashes)

Uploaded Python 3

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