{"id":13658121,"url":"https://github.com/tryexceptpass/sofi","last_synced_at":"2025-04-05T00:06:13.138Z","repository":{"id":49635830,"uuid":"51976434","full_name":"tryexceptpass/sofi","owner":"tryexceptpass","description":"an OS agnostic UI module for Python","archived":false,"fork":false,"pushed_at":"2021-06-11T17:45:13.000Z","size":262,"stargazers_count":388,"open_issues_count":29,"forks_count":47,"subscribers_count":36,"default_branch":"master","last_synced_at":"2025-03-28T23:04:04.214Z","etag":null,"topics":["gui","python","widget"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tryexceptpass.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-18T03:36:39.000Z","updated_at":"2025-02-23T19:27:41.000Z","dependencies_parsed_at":"2022-09-04T15:32:31.499Z","dependency_job_id":null,"html_url":"https://github.com/tryexceptpass/sofi","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tryexceptpass%2Fsofi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tryexceptpass%2Fsofi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tryexceptpass%2Fsofi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tryexceptpass%2Fsofi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tryexceptpass","download_url":"https://codeload.github.com/tryexceptpass/sofi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266563,"owners_count":20910836,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gui","python","widget"],"created_at":"2024-08-02T05:00:56.539Z","updated_at":"2025-04-05T00:06:13.115Z","avatar_url":"https://github.com/tryexceptpass.png","language":"Python","readme":"[![Build Status](https://travis-ci.org/tryexceptpass/sofi.svg?branch=master)](https://travis-ci.org/tryexceptpass/sofi) [![Stories in Ready](https://badge.waffle.io/tryexceptpass/sofi.png?label=ready\u0026title=Tasks%20Ready)](https://waffle.io/tryexceptpass/sofi) [![Join the chat at https://gitter.im/try-except-pass/sofi](https://badges.gitter.im/try-except-pass/sofi.svg)](https://gitter.im/try-except-pass/sofi?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n[![Documentation Status](https://readthedocs.org/projects/sofi-gui-framework/badge/?version=latest)](http://sofi-gui-framework.readthedocs.io/en/latest/?badge=latest)\n[![Say Thanks!](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/tryexceptpass)\n\n## Overview\n`sofi` is an OS agnostic UI module for Python.\n\nThe main idea is to allow rapid, pythonic GUI development using standard web-based widgets from `Bootstrap` and\nother common HTML5 libraries and package them in such a way that all event processing is done within python using\n`websockets`.\n\nThis was developed as an exercise in poking at the underlying technologies and to see what comes out of merging them together. For a better overview of why it came to be, feel free to take a look at this post: [A Python Ate My GUI - Part 3: Implementation](http://tryexceptpass.org/article/a-python-ate-my-gui-3)\n\nWe're in a **beta** stage for now, feedback appreciated.\n\n## Usage\nThe `sofi.app.Sofi` object runs the main event thread with `.start()` and provides a number of functions to help manipulate the state of the user interface, which is actually a webpage opened in a browser. The `register` and `unregister` methods provide the mechanism for subscribing to events through callbacks, while the remaining functions (`append`, `replace`, `style`, etc.) wrap the commands intended to dynamically update the widgets (which are actual HTML elements).\n\nThe commands map directly to `D3` or `jQuery` methods present in the `sofi.js` library that's loaded during initialization and is responsible for performing the requested operations.\n\nFollowing basic practices from bootstrap, the widgets should be within a `Container`. The base page itself is represented with the `View` class, which wraps the necessary head, body and style tags that will contain the widgets.\n\nBelow is a quick idea of how to get things going, but check out `sample.py` for a more complicated hello world which instantiates a navbar item, adds a few links, creates some buttons, registers events and performs some timed updates.\n\n\n```python\nfrom sofi.app import Sofi\nfrom sofi.ui import Container, Paragraph, Heading, View\n\nimport json\nimport asyncio\n\n\nasync def onload(event):\n    # Every page is built on top of a View object, which contains the \u003chead\u003e and \u003cbody\u003e tags that are filled in by the other objects\n    v = View()\n\n    # Make a bootstrap container in which to put all your widgets\n    c = Container()\n\n    # Add a heading and paragraph to the container\n    c.addelement(Heading(2, \"Dude!\"))\n    c.addelement(Paragraph(\"Where's My Car?\"))\n\n    # Add the container to the view\n    v.addelement(c)\n\n    # Tell the UI to load the HTML generated by the view\n    app.load(str(v))\n\n\n# Instantiate the application\napp = Sofi()\n\n# Register the event handler that runs when the UI is ready to receive commands\napp.register('init', onload)\n\n# Start the app (opens the default browser) and listen for events\napp.start()\n```\n\n## What do the widgets look like?\n\n![sample.py](https://cdn-images-1.medium.com/max/800/1*euug6f885sjtRPOMt_Vc6g.png)\n\n![timeline.py](https://cdn-images-1.medium.com/max/800/1*AmbFclbXWFdIRYbpa0cyBw.png)\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftryexceptpass%2Fsofi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftryexceptpass%2Fsofi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftryexceptpass%2Fsofi/lists"}