I heard about Toga from twitter. Apparently it was introduced at PyConAU. I took an hour to whip up a small app that will let you touch buttons to launch fabric tasks.
None of them can take arguments, so it relies on defaults and a fully-stocked set of 'env' variables, but that's ok, this is just a silly hack to explore a new gui framework.
What I mean is, it seems to have a long way to go in the documentation front before I'd use it for anything serious, but I'm excited for the possibilities and it was impressive how easy it was writing a quick app as compared to my experiences with pyobjectivec and pygtk.
If you have an existing fabfile, you can pip install toga
and run this little app.
from __future__ import print_function, unicode_literals, absolute_import
import os
import toga
from fabric import state
from fabric.main import load_fabfile
from fabric.tasks import execute
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
FABFILE = os.path.join(BASE_DIR, 'fabfile.py')
docstring, callables, default = load_fabfile(FABFILE)
state.commands.update(callables)
def button_handler(widget, *args, **kwargs):
execute(
widget.label,
hosts=[],
roles=[],
exclude_hosts=[],
*args, **kwargs
)
if __name__ == '__main__':
app = toga.App('Fabric App', 'com.issackelly.fabricapp')
container = toga.Container()
btn_height = 20
this_height = container.TOP
for name in callables:
button = toga.Button(name, on_press=button_handler)
container.add(button)
container.constrain(button.TOP == this_height)
container.constrain(button.HEIGHT == btn_height)
container.constrain(button.WIDTH == 150)
this_height += btn_height
app.main_window.size = (150, btn_height * (len(callables) + 1))
app.main_window.content = container
app.main_loop()
3rd August 2014
I won't ever give out your email address. I don't publish comments but if you'd like to write to me then you could use this form.
I'm Issac. I live in Oakland. I make things for fun and money. I use electronics and computers and software. I manage teams and projects top to bottom. I've worked as a consultant, software engineer, hardware designer, artist, technology director and team lead. I do occasional fabrication in wood and plastic and metal. I run a boutique interactive agency with my brother Kasey and a roving cast of experts at Kelly Creative Tech. I was the Director of Technology for Nonchalance during the The Latitude Society project. I was the Lead Web Developer and then Technical Marketing Engineer at Nebula, which made an OpenStack Appliance. I've been building things on the web and in person since leaving Ohio State University's Electrical and Computer engineering program in 2007. Lots of other really dorky things happened to me before that, like dropping out of high school to go to university, getting an Eagle Scout award, and getting 6th in a state-wide algebra competition. I have an affinity for hopscotch.