An open API service indexing awesome lists of open source software.

https://github.com/meyer1994/ugh

Use JSON templates to create terminal UI with urwid
https://github.com/meyer1994/ugh

curses template terminal ui urwid xml

Last synced: 19 days ago
JSON representation

Use JSON templates to create terminal UI with urwid

Awesome Lists containing this project

README

          

# UGH
Use JSON templates to create terminal UI with urwid

[![Build Status](https://travis-ci.org/meyer1994/ugh.svg?branch=master)](https://travis-ci.org/meyer1994/ugh)
[![Code Coverage](https://codecov.io/gh/meyer1994/ugh/branch/master/graph/badge.svg)](https://codecov.io/gh/meyer1994/ugh)
PS: UGH does not mean anything. It is what I think when I need to use urwid (still better than curses).

## Usage:
1. Define the `class` attribute with the name of the class you want to use;
2. Define the variables of the constructor as if you were coding it normally;
3. ????
4. Profit?

---

Simple example used to show a centered Text widget written 'nice' with red
background.

[text.py](examples/text.py)
```python
import urwid
import json

import ugh

def exit_q(key):
if key in ('q', 'Q'):
raise urwid.ExitMainLoop()

json_string = '''
{
"class": "Filler",
"body": {
"class": "AttrMap",
"w": {
"class": "Text",
"markup": "nice",
"align": "center"
},
"attr_map": "streak"
}
}
'''

palette = [('streak', 'black', 'dark red')]
w_dict = json.loads(json_string)
t = ugh.construct(w_dict)
loop = urwid.MainLoop(t, palette, unhandled_input=exit_q)
loop.run()
```

## TODO
- ~~Handle lists and tuples.~~

- ~~Better way to handle tuples.~~

- ~~Handle callbacks (it breaks everything, for now).~~