Example #1
0
def menu(password):

    from functools import partial
    from termenu.app import AppMenu
    import requests

    def make_action((params, callback)):
        def action():
            assert len(params)<=3
            url = URL.format(*params[:2], PASSWORD=password)
            if len(params) > 2:
                url += "&p=%" + params[2]
            print url, "->",
            ret = requests.get(url)
            print ret, "->",
            if callback:
                print "..."
                return callback(ret.content)
            else:
                print repr(ret.content)
        return action

    def convert(d, typ, parents=[]):
        if isinstance(d, dict):
            for (k, v) in d.iteritems():
                for item in convert(v, make_action, parents=parents+[k]):
                    yield item
        else:
            yield " - ".join(parents), typ(d)

    actions = sorted(convert(COMMANDS, make_action))
    AppMenu.show_menu("GoPro", actions)
Example #2
0
 def there():
     ret = AppMenu.show("Where's there?",
                        "Spain France Albania".split() +
                        [("Quit", AppMenu.quit)],
                        multiselect=True,
                        back_on_abort=True)
     print(ret)
     return ret
Example #3
0
def go():
    def back():
        print("Going back.")
        AppMenu.back()

    def there():
        ret = AppMenu.show("Where's there?",
                           "Spain France Albania".split() +
                           [("Quit", AppMenu.quit)],
                           multiselect=True,
                           back_on_abort=True)
        print(ret)
        return ret

    return AppMenu.show("Go Where?", [("YELLOW<<Back>>", back),
                                      ("GREEN<<There>>", there)])
Example #4
0
def go():
    def back():
        print("Going back.")
        AppMenu.back()

    def there():
        ret = AppMenu.show("Where's there?",
            "Spain France Albania".split() + [("Quit", AppMenu.quit)],
            multiselect=True, back_on_abort=True)
        print(ret)
        return ret

    return AppMenu.show("Go Where?", [
        ("YELLOW<<Back>>", back),
        ("GREEN<<There>>", there)
    ])
Example #5
0
def leave():
    print("Leave...")
    AppMenu.quit()
Example #6
0
 def back():
     print("Going back.")
     AppMenu.back()
Example #7
0
import time
from termenu.app import AppMenu


def leave():
    print("Leave...")
    AppMenu.quit()


def go():
    def back():
        print("Going back.")
        AppMenu.back()

    def there():
        ret = AppMenu.show("Where's there?",
                           "Spain France Albania".split() +
                           [("Quit", AppMenu.quit)],
                           multiselect=True,
                           back_on_abort=True)
        print(ret)
        return ret

    return AppMenu.show("Go Where?", [("YELLOW<<Back>>", back),
                                      ("GREEN<<There>>", there)])


if __name__ == "__main__":
    AppMenu.show("Make your MAGENTA<<decision>>", [("RED<<Leave>>", leave),
                                                   ("BLUE<<Go>>", go)])
Example #8
0
 def back():
     print("Going back.")
     AppMenu.back()
Example #9
0
def leave():
    print("Leave...")
    AppMenu.quit()
Example #10
0
 def there():
     ret = AppMenu.show("Where's there?",
         "Spain France Albania".split() + [("Quit", AppMenu.quit)],
         multiselect=True, back_on_abort=True)
     print(ret)
     return ret
Example #11
0
import time
from termenu.app import AppMenu

def leave():
    print("Leave...")
    AppMenu.quit()

def go():
    def back():
        print("Going back.")
        AppMenu.back()

    def there():
        ret = AppMenu.show("Where's there?",
            "Spain France Albania".split() + [("Quit", AppMenu.quit)],
            multiselect=True, back_on_abort=True)
        print(ret)
        return ret

    return AppMenu.show("Go Where?", [
        ("YELLOW<<Back>>", back),
        ("GREEN<<There>>", there)
    ])

if __name__ == "__main__":
    AppMenu.show("Make your MAGENTA<<decision>>", [
        ("RED<<Leave>>", leave),
        ("BLUE<<Go>>", go)
    ])