
Traditional GUI packages target GUI creation for end-users. This means that they're extensible, precisely configurable, and set up in a way that keeps code reusability high while keeping code execution low. Those great advantages all come at a cost: complexity for the programmer.
Rapid-Gui tries to approach GUI's slightly differently. Instead of attempting to provide tools that allow to create the best possible end product, it is made with the programmer in mind. As such, it can be added to code that isn't even written with GUIs in mind - one line at the top of the file is sufficient to start a new window, and with one method call your data is visualized.
Let's say we have a script that does something computation heavy, containing a long loop:
import time, random
def do_heavy_work():
time.sleep(random.choide(range(3)))
def my_super_duper_long_function():
pct = 0 # percentage
for i in range(5):
pct = i * 1/5
do_heavy_work()
pct = 1
And we'd like to get some visual feedback in the form of a button and a progress bar.
(Still not implemented)
pip3 install rapidgui
python3 -m rapidgui

import time, random
import rapidgui
app = rapidgui.load("example.json")
def do_heavy_work():
time.sleep(random.choice(range(3)))
def my_super_duper_long_function():
pct = 0
app("myprogressbar").set_pct(pct)
for i in range(20):
pct = i * 1 / 20
app("myprogressbar").set_pct(pct*100)
do_heavy_work()
app("myprogressbar").set_pct(100)
print("Done doing heavy work.")
@app("mybutton")
def on_pressed():
app("mybutton").set_enabled(False)
my_super_duper_long_function()
And out comes the GUI defined in the editor, with a working button & progress bar.
subp = subprocess.spawn("ls -a")
app("MyTerminalViewer").display_subprocess(subp)
data = range(100)
app("MyPlot").plot(data, data) # x, y data etc.
form = app("MyForm")
button = app("MyButton")
form.set_submit_button(button) # or add callback to button calling form.submit()
@app("MyForm")
def on_submit(text):
print(text)
@app("MyButton")
def on_press():
filename = app.select_file()
folder = app.select_folder()
files = app.select_files()
app("MyDisplay").set_content("print('hello world')", syntax="Python")
app("MyDisplay").set_content(open('kitten.png'))
data = [["Max", "Mustermann"] for i in range(20)]
app("MyTable").set_content(data)
app("MyTable").set_header("Firstname", "Lastname")
app("MyTable").set_editable(True)
@app("MyTable")
def on_edit(edited_data):
pass
@app("MyButton")
def on_pressed():
app("MyPlot").plot(app("MyTable").get_data(), range(1000))
app("MyCheckbox").set_editable(False)
app("myCheckbox").set(False)
@app.timer(13, "s")
def check_server_online():
app("MyCheckbox").set(is_server_online())
@app.timer(1, "s")
def player_count():
app("MyLabel").set(get_player_count())
@app.shortcut("Ctrl+S")
def save():
self.save_file()
The example in the vision has been fully realized:
goal.pyimport time, random
import rapidgui
app = rapidgui.load("example.json")
def do_heavy_work():
time.sleep(random.choice(range(3)))
def my_super_duper_long_function():
pct = 0
app("myprogressbar").set_pct(pct)
for i in range(20):
pct = i * 1 / 20
app("myprogressbar").set_pct(pct*100)
do_heavy_work()
app("myprogressbar").set_pct(100)
print("Done doing heavy work.")
@app("mybutton")
def on_pressed():
app("mybutton").set_enabled(False)
my_super_duper_long_function()
example.json{
"app-properties": {
"width": 1000,
"height": 500,
"background_color": [255, 255, 255, 255]
},
"components" : [
{
"meta": {
"type": "button",
"identifier": "mybutton"
},
"properties": {
"x": 100,
"y": 100,
"width": 200,
"height": 50,
"label_text": "Hello",
"background_color": [164, 219, 211, 255],
"line_color": null,
"enabled": true
}
},
{
"meta": {
"type": "progressbar",
"identifier": "myprogressbar"
},
"properties": {
"x": 500,
"y": 100,
"width": 400,
"height": 50,
"background_color": [230, 230, 230, 255],
"pct": 0,
"bar_color": [164, 219, 211, 255]
}
}
]
}

Contributions are welcome! If you need help with anything, please ask.