Ejemplo n.º 1
0
async def make_user_sub_menu(menu, label, item):
    # details, actions on single multisig wallet
    user = item.arg

    async def delete_user(menu, label, item):
        if not await ux_confirm('Delete user:\n %s\n' % item.arg):
            return

        Users.delete(item.arg)
        await ux_dramatic_pause('Deleted.', 3)

        from ux import the_ux
        the_ux.pop()
        m = the_ux.top_of_stack()
        m.update_contents()

    # get details: not much
    info = Users.lookup(user)
    if not info:
        return

    if info.auth_mode == USER_AUTH_TOTP:
        dets = "TOTP: " + ('unused' if not info.last_counter else 'active')
    elif info.auth_mode == USER_AUTH_HOTP:
        dets = "HOTP: count=%d" % info.last_counter
    elif info.auth_mode == USER_AUTH_HMAC:
        dets = "Password: "******"%s"' % user),  # does nothing, it's a title
        MenuItem(dets),
        MenuItem('Delete User', f=delete_user, arg=user),
    ]

    return rv
Ejemplo n.º 2
0
async def electrum_skeleton(*a):
    # save xpub, and some other public details into a file: NOT MULTISIG

    if not await ux_show_story(electrum_export_story()):
        return

    import chains
    ch = chains.current_chain()

    # pick segwit or classic derivation+such
    from public_constants import AF_CLASSIC, AF_P2WPKH, AF_P2WPKH_P2SH
    from menu import MenuSystem, MenuItem

    # Ordering and terminology from similar screen in Electrum. I prefer
    # 'classic' instead of 'legacy' personallly.
    rv = []

    if AF_CLASSIC in ch.slip132:
        rv.append(
            MenuItem("Legacy (P2PKH)",
                     f=electrum_skeleton_step2,
                     arg=AF_CLASSIC))
    if AF_P2WPKH_P2SH in ch.slip132:
        rv.append(
            MenuItem("P2SH-Segwit",
                     f=electrum_skeleton_step2,
                     arg=AF_P2WPKH_P2SH))
    if AF_P2WPKH in ch.slip132:
        rv.append(
            MenuItem("Native Segwit", f=electrum_skeleton_step2,
                     arg=AF_P2WPKH))

    return MenuSystem(rv)
Ejemplo n.º 3
0
def resources_children(request):
    children = []
    """
    children.append (MenuItem(
         _("By theme area"),
         url='/risorse-utili-roma-lazio-aree-tematiche',
         weight=80,
        ))
    
    if request.user.is_authenticated():
        children.append (MenuItem(
             _("By category"),
             url='/risorse-utili-roma-lazio-categorie',
             weight=80,
       ))
    """
    children.append(MenuItem(
        _("By category"),
        url='/categorie',
        weight=80,
    ))
    children.append(
        MenuItem(
            _("By affiliation"),
            url='/reti-di-risorse',
            weight=80,
        ))
    """
    if request.user.is_authenticated():
        children.append (MenuItem(
             _("Da controllare"),
             url='/analisi-risorse',
             weight=80,
            ))
        children.append (MenuItem(
         _("Top contributors"),
             url='/poi-contributors',
             weight=80,
            ))
    """
    if False:
        children.append(
            MenuItem(
                _("Advanced search"),
                url='/cerca/',
                weight=80,
            ))
        children.append(
            MenuItem(
                _("How to search"),
                url='/help/search',
                weight=80,
            ))
        children.append(
            MenuItem(
                _("Suggest a resource"),
                url='/nuova-risorsa',
                weight=80,
            ))
    return children
Ejemplo n.º 4
0
	def ready(self):
		# Add two items to our main menu
		Menu.add_item("main", MenuItem("Informacje o koncie",reverse("am_userInfo"),weight=10,icon="tools"))
		Menu.add_item("main", MenuItem("zmień dane",reverse("am_changeUserdata"),weight=20,icon="report"))
		Menu.add_item("main", MenuItem("zmień hasło",reverse("am_changeUserpassword"),weight=30,icon="report"))
		Menu.add_item("main", MenuItem("twoje ankiety",reverse("am_userSurveys"),weight=40,icon="report"))
		Menu.add_item("main", MenuItem("statystyki i aktywność użytkownika",reverse("am_userActivity"),weight=50,icon="report"))
Ejemplo n.º 5
0
async def electrum_skeleton(*A):
    # save xpub, and some other public details into a file
    import chains

    ch = chains.current_chain()

    if not await ux_show_story('''\
This saves a skeleton Electrum wallet file onto the MicroSD card. \
You can then open that file in Electrum without ever connecting this Coldcard to a computer.\n
Choose an address type for the wallet on the next screen.
''' + SENSITIVE_NOT_SECRET):
        return

    # pick segwit or classic derivation+such
    from public_constants import AF_CLASSIC, AF_P2WPKH, AF_P2WPKH_P2SH
    from menu import MenuSystem, MenuItem

    # Ordering and terminology from similar screen in Electrum. I prefer
    # 'classic' instead of 'legacy' personallly.
    rv = []

    if AF_CLASSIC in ch.slip132:
        rv.append(MenuItem("Legacy (P2PKH)", f=electrum_skeleton_step2, arg=AF_CLASSIC))
    if AF_P2WPKH_P2SH in ch.slip132:
        rv.append(MenuItem("P2SH-Segwit", f=electrum_skeleton_step2, arg=AF_P2WPKH_P2SH))
    if AF_P2WPKH in ch.slip132:
        rv.append(MenuItem("Native Segwit", f=electrum_skeleton_step2, arg=AF_P2WPKH))

    return MenuSystem(rv)
Ejemplo n.º 6
0
    def construct(cls):
        # Dynamic menu with user-defined user names
        from actions import import_multisig

        async def no_users_yet(*a):
            # action for 'no wallets yet' menu item
            await ux_show_story(
                "You don't have any user accounts defined yet. USB is used to define new users, and their associated secrets."
            )

        users = Users.list()
        if not users:
            rv = [MenuItem('(no users yet)', f=no_users_yet)]
        else:
            rv = [
                MenuItem('%d user%s:' %
                         (len(users), 's' if len(users) != 1 else ''))
            ]
            for u in users:
                rv.append(MenuItem('"%s"' % u, menu=make_user_sub_menu, arg=u))

        # other static items?
        #rv.append(MenuItem('', f=import_multisig))

        return rv
Ejemplo n.º 7
0
 def visit_door(self, title: str = "There is a door here") -> None:
     entries = [
         MenuItem(
             key="K_1",
             label="[1] Break it",
             subtitle="If the door is trapped, this will trigger the trap",
             action=self.break_door,
         )
     ]
     if self.hero.room.trap is None or self.hero.room.trap.hide_dc > 0:
         entries.append(
             MenuItem(key="K_2",
                      label="[2] Check it for traps",
                      action=self.search_traps))
     else:
         entries.append(
             MenuItem(
                 key="K_2",
                 label="[2] Disarm trap",
                 subtitle="Failure will trigger the trap",
                 action=self.disarm_trap,
             ))
     entries.append(
         MenuItem(key="K_3",
                  label="[3] Leave it alone",
                  action=self.hero.retreat))
     self.extend(entries, MenuID.DOOR)
     self.add_menu(
         Menu(
             title=title,
             subtitle="What next?",
             entries=entries,
             cancel=self.hero.retreat,
         ))
Ejemplo n.º 8
0
    def events(self, arg=None, menuw=None):
        events = self.Zm.list_events(where="MonitorId = %d" % arg, orderby=" EventId DESC")
        events_menu_items = []
        for e in events:
            item = MenuItem(e["Name"], self.event, e["EventId"], skin_type="image")
            image_path = "%s/%d/%d/%03d-%s" % (
                config.ZONEMINDER_EVENTS_DIR,
                e["MonitorId"],
                e["EventId"],
                e["FrameId"],
                "analyse.jpg",
            )
            description = "Monitor: %s\nCause: %s\nTime: %s\nDuration: %s" % (
                e["MonitorName"],
                e["Cause"],
                e["StartTime"],
                e["Length"],
            )
            item.info = {"description": description}
            item.image = image_path
            events_menu_items.append(item)
        if menuw:
            menuw.refresh()

        events_menu = Menu(_("Events"), events_menu_items)
        menuw.pushmenu(events_menu)
        menuw.refresh()
Ejemplo n.º 9
0
    def monster_encounter(self) -> None:
        assert self.hero.room.monster

        entries = [
            MenuItem(
                key="K_1",
                label="[1] Chaaaaarge!",
                subtitle="The monster dies, but may hurt you.",
                action=self.fight,
            ),
            MenuItem(
                key="K_2",
                label="[2] Try to escape",
                subtitle="You retreat, but the monster may hurt you.",
                action=self.escape,
            ),
        ]
        self.extend(entries, MenuID.MONSTER)
        self.add_menu(
            Menu(
                title="There is a monster here!",
                subtitle="What next?",
                entries=entries,
                cancel=self.escape,
            ))
Ejemplo n.º 10
0
    def visit_treasure(self, title: str = "There is a {} here") -> None:
        assert self.hero.room.loot

        item = self.hero.room.loot

        drop = self.hero.check_pick_up()
        if drop:
            if drop.kind is item.kind:
                self.add_message(
                    f"The {item.kind.name} here are exactly like yours.")
                return
            else:
                subtitle = f"You will have to drop your {drop.kind.name}"
        else:
            subtitle = ""

        entries = [
            MenuItem(
                key="K_1",
                label="[1] Pick it up",
                subtitle=subtitle,
                action=self.hero.pick_up,
            ),
            MenuItem(key="K_2", label="[2] Leave it", action=lambda: None),
        ]
        self.add_menu(
            Menu(
                title=title.format(item.kind.name),
                subtitle=item.kind.description,
                entries=entries,
            ))
Ejemplo n.º 11
0
async def electrum_skeleton(*a):
    # save xpub, and some other public details into a file: NOT MULTISIG

    ch = await ux_show_story(electrum_export_story(), escape='1')

    account_num = 0
    if ch == '1':
        account_num = await ux_enter_number('Account Number:', 9999)
    elif ch != 'y':
        return

    # pick segwit or classic derivation+such
    from public_constants import AF_CLASSIC, AF_P2WPKH, AF_P2WPKH_P2SH
    from menu import MenuSystem, MenuItem

    # Ordering and terminology from similar screen in Electrum. I prefer
    # 'classic' instead of 'legacy' personallly.
    rv = []

    rv.append(
        MenuItem("Legacy (P2PKH)",
                 f=electrum_skeleton_step2,
                 arg=(AF_CLASSIC, account_num)))
    rv.append(
        MenuItem("P2SH-Segwit",
                 f=electrum_skeleton_step2,
                 arg=(AF_P2WPKH_P2SH, account_num)))
    rv.append(
        MenuItem("Native Segwit",
                 f=electrum_skeleton_step2,
                 arg=(AF_P2WPKH, account_num)))

    return MenuSystem(rv)
Ejemplo n.º 12
0
    def visit_trap(self,
                   title: str = "You get carefully closer to the {}") -> None:
        assert self.hero.room.trap

        trap = self.hero.room.trap
        if trap.hide_dc != 0:
            self.trigger_trap()
        else:
            entries = [
                MenuItem(key="K_1",
                         label="[1] Retreat",
                         action=self.hero.retreat),
                MenuItem(
                    key="K_2",
                    label="[2] Disarm trap",
                    subtitle="Failure MAY trigger the trap",
                    action=self.disarm_trap,
                ),
                MenuItem(
                    key="K_3",
                    label="[3] Walk through trap",
                    subtitle=
                    "Will trigger the trap, but you'll be able to walk past",
                    action=self.trigger_trap,
                ),
            ]
            self.add_menu(
                Menu(
                    title=title.format(trap.name),
                    subtitle="What next?",
                    entries=entries,
                    cancel=self.hero.retreat,
                ))
Ejemplo n.º 13
0
    def hero_level_up(self, level: int) -> None:
        increases_left = 2

        def powerup(ability: str) -> None:
            nonlocal increases_left
            s = getattr(self.hero, ability)
            s.score += 2
            setattr(self.hero, ability, s)
            increases_left -= 1
            if increases_left:
                self.add_menu(
                    Menu(
                        title=f"You still have {increases_left} ability "
                        f"increase{'s'*(increases_left != 1)}",
                        subtitle=
                        f"You can increase the same ability multiple times",
                        entries=entries,
                    ))

        if level > self.hero.level:
            diff = level - self.hero.level
            self.hero.level = level
            entries = [
                MenuItem(
                    key="K_1",
                    label="[1] Increase strength",
                    subtitle=
                    "Improve 5% your effectiveness at combat and breaking doors",
                    action=lambda: powerup("strength"),
                ),
                MenuItem(
                    key="K_2",
                    label="[2] Increase agility",
                    subtitle=
                    "Improve 5% your chance of escaping and disarming traps",
                    action=lambda: powerup("agility"),
                ),
                MenuItem(
                    key="K_3",
                    label="[3] Increase health",
                    subtitle="Gives you an extra hit point per level",
                    action=lambda: powerup("health"),
                ),
                MenuItem(
                    key="K_4",
                    label="[4] Increase awareness",
                    subtitle=
                    "Improve 5% your chance of detecting traps and secret doors",
                    action=lambda: powerup("awareness"),
                ),
            ]
            self.add_menu(
                Menu(
                    title=
                    f"You have gained {diff} level{'' if diff == 1 else 's'}!",
                    subtitle=
                    f"You can increase {increases_left} of your abilities",
                    entries=entries,
                ))
Ejemplo n.º 14
0
 def __init__(self, parent, name, arg):
     logger.debug(
         'AlbumTreeBranchMenu.__init__(parent=%r, name=%r, arg=%r)', parent,
         name, arg)
     MenuItem.__init__(self, name, parent=parent)
     self.parent = parent
     self.branch = arg[0]
     self.data = arg[1]
Ejemplo n.º 15
0
 def setgame(self,x):
     print("rande.setgame")
     #self.setgame(self)
     startMenu.setitem(4,MenuItem("Start",self.startgame))
     startMenu.setitem(2,MenuItem(self.name,startMenu.show))
     #self.game.setgame(self)
     #print(self)
     startMenu.show(0)
Ejemplo n.º 16
0
 def __init__(self, parent, tree):
     logger.debug('AlbumTreeMainMenu.__init__(parent=%r)', parent)
     MenuItem.__init__(self,
                       name=_('Album Tree 2'),
                       parent=parent,
                       skin_type='album_tree',
                       type='audio')
     self.parent = parent
     self.tree = tree
Ejemplo n.º 17
0
    def buildMenu(self,
                  drink_list,
                  drink_options,
                  alcoholic_drinks_enabled=False):
        # create a new main menu
        m = Menu("Main Menu")

        # add drink options
        drink_opts = []
        for d in drink_list:
            # check if allowed by admin button
            if alcoholic_drinks_enabled == False:
                # check if the drink has alcohol
                if d["alcoholic"] == False:  # -----!!!!-----
                    drink_opts.append(
                        MenuItem('drink', d["name"],
                                 {"ingredients": d["ingredients"]
                                  }))  # -----!!!!-----
            else:
                drink_opts.append(
                    MenuItem('drink', d["name"],
                             {"ingredients": d["ingredients"]}))

        configuration_menu = Menu("Configure")

        # add pump configuration options
        pump_opts = []
        for p in sorted(self.pump_configuration.keys()):
            config = Menu(self.pump_configuration[p]["name"])
            # add fluid options for each pump
            for opt in drink_options:
                # star the selected option
                selected = "*" if opt["value"] == self.pump_configuration[p][
                    "value"] else ""
                config.addOption(
                    MenuItem('pump_selection', opt["name"], {
                        "key": p,
                        "value": opt["value"],
                        "name": opt["name"]
                    }))
            # add a back button so the user can return without modifying
            config.addOption(Back("Back"))
            config.setParent(configuration_menu)
            pump_opts.append(config)

        # add pump menus to the configuration menu
        configuration_menu.addOptions(pump_opts)
        # add a back button to the configuration menu
        configuration_menu.addOption(Back("Back"))
        # adds an option that cleans all pumps to the configuration menu
        configuration_menu.addOption(MenuItem('clean', 'Clean'))
        configuration_menu.setParent(m)

        m.addOptions(drink_opts)
        m.addOption(configuration_menu)
        # create a menu context
        self.menuContext = MenuContext(m, self)
Ejemplo n.º 18
0
    async def next_menu(self, idx, choice):

        words = WordNestMenu.words
        cls = self.__class__

        if choice.label[-1] == '-':
            ch = letter_choices(choice.label[0:-1])

            return cls(items=[MenuItem(i, menu=self.next_menu) for i in ch])

        # terminal choice, start next word
        words.append(choice.label)

        #print(("words[%d]: " % len(words)) + ' '.join(words))
        assert len(words) <= self.target_words

        if len(words) == 23 and self.has_checksum:
            # we can provide final 8 choices, but only for 24-word case
            final_words = list(bip39.a2b_words_guess(words))

            async def picks_chk_word(s, idx, choice):
                # they picked final word, the word includes valid checksum bits
                words.append(choice.label)
                await cls.done_cb(words.copy())

            items = [MenuItem(w, f=picks_chk_word) for w in final_words]
            items.append(MenuItem('(none above)', f=self.explain_error))
            return cls(is_commit=True, items=items)

        # add a few top-items in certain cases
        if len(words) == self.target_words:
            if self.has_checksum:
                try:
                    bip39.a2b_words(' '.join(words))
                    correct = True
                except ValueError:
                    correct = False
            else:
                correct = True

            # they have checksum right, so they are certainly done.
            if correct:
                # they are done, don't force them to do any more!
                return await cls.done_cb(words.copy())
            else:
                # give them a chance to confirm and/or start over
                return cls(is_commit=True,
                           items=[
                               MenuItem('(INCORRECT)', f=self.explain_error),
                               MenuItem('(start over)', f=self.start_over)
                           ])

        # pop stack to reset depth, and start again at a- .. z-
        cls.pop_all()

        return cls(items=None, is_commit=True)
Ejemplo n.º 19
0
 def update_menu(self):
     # Reconstruct the menu contents based on our state.
     self.my_menu.replace_items([
         MenuItem("Don't make PDF" if not self.template_fn else 'Making PDF',
                     f=self.pick_template, predicate=self.can_do_qr),
         MenuItem('Classic Address' if not self.is_segwit else 'Segwit Address',
                     chooser=self.addr_format_chooser),
         MenuItem('Use Dice', f=self.use_dice),
         MenuItem('GENERATE WALLET', f=self.doit),
     ], keep_position=True)
Ejemplo n.º 20
0
    def __init__(self, parent, Zm):
        Item.__init__(self, parent)
        self.zm = Zm
        self.name   = _('Stream')
        self.menus = [
                MenuItem(_('Montage'), self.montage)
        ]

        names = Zm.list_monitor()
        for (id, name, width, height) in names :
            self.menus.append(MenuItem(name.capitalize(), self.live, id))
Ejemplo n.º 21
0
 def actions(self):
     """
     return the default action
     """
     return [
         (self.browse, _('Browse episodes')),
         (self.play_all, _('Play all episodes')),
         (self.mark_all_to_keep, _('Keep all episodes')),
         (self.confirm_delete, _('Delete all episodes')),
         MenuItem(_('Search for more of this program'), search_for_more, (self, self.name)),
         MenuItem( _('Add to favorites'), add_to_favorites, (self, self.name)),
     ]
Ejemplo n.º 22
0
 def actions(self):
     """
     return the default action
     """
     actions = VideoItem.actions(self)
     items = actions[0:2]
     items.append((self.mark_to_keep, self.keep and _('Unmark to Keep') or _('Mark to Keep')))
     items.append((self.mark_as_watched, self.watched and _('Unmark as Watched') or _('Mark as Watched')))
     items.append(MenuItem(_('Search for more of this program'), search_for_more, (self, self.video_item.name)))
     items.append(MenuItem(_('Add to favorites'), add_to_favorites, (self, self.video_item.name)))
     items = items + actions[2:]
     return items
Ejemplo n.º 23
0
 def __init__(self, path, parent):
     self.parent = parent
     items = [
         MenuItem("Classic P2PKH", f=self.done, arg=(path, AF_CLASSIC)), 
         MenuItem("Segwit P2WPKH", f=self.done, arg=(path, AF_P2WPKH)), 
         MenuItem("P2SH-P2WPKH", f=self.done, arg=(path, AF_P2WPKH_P2SH)), 
     ]
     super().__init__(items)
     if path.startswith("m/84'"):
         self.goto_idx(1)
     if path.startswith("m/49'"):
         self.goto_idx(2)
Ejemplo n.º 24
0
    def setUp(self):
        """
        Build some menus for our tests
        """
        self.kids3_2_desired_title = None
        def kids3_2_title(request):
            "Allow the title of kids3-2 to be changed"
            if self.kids3_2_desired_title is not None:
                return "-".join([request.path, self.kids3_2_desired_title])
            return 'kids3-2'

        def kids2_2_check(request):
            "Hide kids2-2 whenever the request path ends with /hidden"
            if request.path.endswith('/hidden'):
                return False
            return True

        # Ensure we can pass children as tuples (or other iterables, like generators)
        # Following the implementation of sorted children there was a bug reported due to children
        # being passed as a tuple, which has no .sort method
        # See: https://github.com/borgstrom/django-simple-menu/issues/38
        def kids2():
            "Generator for kids2"
            class RepeatIterator(object):
                "We need this to be reusable -- http://stackoverflow.com/a/1985733"
                def __iter__(self):
                    yield MenuItem("kids2-1", "/parent2/kids2-1", weight=999)
                    yield MenuItem("kids2-2", "/kids2-2", check=kids2_2_check)
            return RepeatIterator()

        def kids3_1(request):
            "Callable for kids3-1"
            return [
                MenuItem("kids3-1-1", "/parent3/kids3-1/kid1", exact_url=True),
            ]

        kids3 = (
            MenuItem("kids3-1", "/parent3/kids3-1", children=kids3_1),
            MenuItem(kids3_2_title, "/parent3/kids3-2")
        )

        Menu.items = {}
        Menu.sorted = {}
        Menu.loaded = False

        # add our items.  because we set weight to 999 for parent 1 it will become the last child
        # even though it's added first
        Menu.add_item("test", MenuItem("Parent 1", "/parent1", weight=999))
        Menu.add_item("test", MenuItem("Parent 2", "/parent2", children=kids2()))
        Menu.add_item("test", MenuItem("Parent 3", "/parent3", children=kids3))

        self.factory = RequestFactory()
Ejemplo n.º 25
0
async def make_ms_wallet_menu(menu, label, item):
    # details, actions on single multisig wallet
    ms = MultisigWallet.get_by_idx(item.arg)
    if not ms: return

    rv = [
        MenuItem('"%s"' % ms.name, f=ms_wallet_detail, arg=ms),
        MenuItem('View Details', f=ms_wallet_detail, arg=ms),
        MenuItem('Delete', f=ms_wallet_delete, arg=ms),
        MenuItem('Coldcard Export', f=ms_wallet_ckcc_export, arg=ms),
        MenuItem('Electrum Wallet', f=ms_wallet_electrum_export, arg=ms),
    ]

    return rv
Ejemplo n.º 26
0
 def __init__(self, window):
     self.window = window
     self.screen_sizes = self.window.getmaxyx()
     curses.init_pair(99, curses.COLOR_WHITE, curses.COLOR_BLACK)
     self.window.bkgd(' ', curses.color_pair(99))
     sudoku_menu = SudokuMain(self.window).main_menu
     snake_menu = SnakeMain(self.window).main_menu
     main_menu_items = [
         MenuItem('Sudoku', MenuItemCallback(sudoku_menu.display)),
         MenuItem('Snake', MenuItemCallback(snake_menu.display)),
         MenuItem('Exit', MenuItemCallback(lambda: True))
     ]
     self.main_menu = Menu(main_menu_items, self.window, self.screen_sizes)
     self.main_menu.display()
Ejemplo n.º 27
0
def zones_children(request):
    children = []
    if not request.user_agent.is_bot:
        """
        children.append (MenuItem(
             _("My zone"),
             url='/la-mia-zona',
             weight=10,
             ))
        """
        children.append(
            MenuItem(
                _("Macrozones"),
                url='/macrozone',
                weight=10,
            ))
        children.append(
            MenuItem(
                _("Municipalities"),
                url='/municipi',
                weight=10,
            ))
        children.append(MenuItem(
            _("Provinces"),
            url='/province',
            weight=10,
        ))
        """
        children.append(MenuItem(_("Traditional city districts") + " (" + _("map") + ")",
             url='/topo',
             weight=10,
             ))
        
        children.append(MenuItem(_("Zipcode areas") + " (" + _("map") + ")",
             url='/cap',
             weight=80,
             ))
    children.append(MenuItem(_("Zone types") + " (" + _("list") + ")",
             url='/tipi-di-zona',
             weight=80,
             ))
   
    if request.user.is_authenticated():
        children.append(MenuItem("Muoversi a Roma",
                 url='/muoviroma',
                 weight=80,
                 ))
    """
    return children
Ejemplo n.º 28
0
    def __init__(self):
        """
        init the buttonbar
        """
        plugin.DaemonPlugin.__init__(self)
        plugin.register(self, 'buttonbar')
        self.visible = True
        self.bar = None
        self.barfile = ''
        self.surface = None
        self.colors = ['red', 'green', 'yellow', 'blue']
        self.actions = [None, None, None, None]
        if not hasattr(config, 'BUTTONBAR_TVGUIDE_ACTIONS'):
            self.tvguide_actions = [
                MenuItem('-1 Day', action=self.advance_tv_guide, arg=-24),
                MenuItem('-6 Hours', action=self.advance_tv_guide, arg=-6),
                MenuItem('+6 Hours', action=self.advance_tv_guide, arg=6),
                MenuItem('+1 Day', action=self.advance_tv_guide, arg=24)
            ]
        else:
            # Process TV Guide buttons
            self.tvguide_actions = [None, None, None, None]
            for index in range(0, len(self.colors)):
                if config.BUTTONBAR_TVGUIDE_ACTIONS.has_key(
                        self.colors[index]):
                    actionstr = config.BUTTONBAR_TVGUIDE_ACTIONS[
                        self.colors[index]]
                    if actionstr == 'record':
                        self.tvguide_actions[index] = MenuItem(
                            _('Record'),
                            action=self.send_event_to_menu,
                            arg=event.TV_START_RECORDING)
                    elif actionstr == 'info':
                        self.tvguide_actions[index] = MenuItem(
                            _('Full Description'),
                            action=self.show_program_info)
                    elif actionstr == 'now':
                        self.tvguide_actions[index] = MenuItem(
                            _('Now'), action=self.jump_to_now)

                    elif actionstr.startswith('adv:'):
                        hours = eval(actionstr[4:])
                        self.tvguide_actions[index] = MenuItem(
                            'Advance %d hours' % hours,
                            action=self.advance_tv_guide,
                            arg=hours)
                    else:
                        msgtext = _('WARNING: ')
                        msgtext += _(
                            '"%s" is not a valid argument for the button bar. '
                        ) % actionstr
                        _debug_(msgtext, DERROR)

        # Getting current LOCALE
        try:
            locale.resetlocale()
        except:
            pass
Ejemplo n.º 29
0
def drv_entro_start(*a):

    # UX entry
    ch = await ux_show_story('''\
Create Entropy for Other Wallets (BIP-85)

This feature derives "entropy" based mathematically on this wallet's seed value. \
This will be displayed as a 12 or 24 word seed phrase, \
or formatted in other ways to make it easy to import into \
other wallet systems.

You can recreate this value later, based \
only the seed-phrase or backup of this Coldcard.

There is no way to reverse the process, should the other wallet system be compromised, \
so the other wallet is effectively segregated from the Coldcard and yet \
still backed-up.''')
    if ch != 'y': return

    if stash.bip39_passphrase:
        if not await ux_confirm('''You have a BIP39 passphrase set right now and so that will become wrapped into the new secret.'''):
            return

    choices = [ '12 words', '18 words', '24 words', 'WIF (privkey)',
                'XPRV (BIP32)', '32-bytes hex', '64-bytes hex']

    m = MenuSystem([MenuItem(c, f=drv_entro_step2) for c in choices])
    the_ux.push(m)
Ejemplo n.º 30
0
    def draw_menu(self):
        props = ItemProperties(labelcolor='black', bgcolor='yellow',
                               fontsize=22, alpha=0.2)
        hoverprops = ItemProperties(labelcolor='white', bgcolor='blue',
                                    fontsize=22, alpha=0.2)

        menuitems = []
        item = MenuItem(self.fig, "save", props=props, hoverprops=hoverprops,
                        on_select=self.save)

        menuitems.append(item)
        item = MenuItem(self.fig, "new palette", props=props, hoverprops=hoverprops,
                        on_select=self.get_new_palette)
        menuitems.append(item)

        return Menu(self.fig, menuitems)
Ejemplo n.º 31
0
    def __init__(self, Lspline):
        self.Lspline = Lspline
        self.Lspline.Lagrangian = None
        self.FPD = FormParameterDict(self.Lspline.curve)
        self.verbose = True
        #self.fig = figure()
        self.fig, self.ax = plt.subplots()
        self.fig.subplots_adjust(left=0.3)
        prop = ItemProperties(labelcolor='black',
                              bgcolor='white',
                              fontsize=15,
                              alpha=0.2)
        hoverprop = ItemProperties(labelcolor='white',
                                   bgcolor='blue',
                                   fontsize=15,
                                   alpha=0.2)
        menuitems = []
        for label in ('tangent', 'curvature', 'area', 'Xc', 'Yc', 'clear',
                      'done'):

            def onselect(item):
                print('you selected %s' % item.labelstr)
                getattr(self, item.labelstr)()
                return

            item = MenuItem(self.fig,
                            label,
                            props=prop,
                            hoverprops=hoverprop,
                            on_select=onselect)
            menuitems.append(item)
        menu = Menu(self.fig, menuitems)
        plt.show(block=False)
        return
Ejemplo n.º 32
0
 def __onCombolist(self):
     if len(self.data):            
         from menu import PopupMenu, MenuItem
         m = PopupMenu(self.window)
         m.applyStyle(self.menuStyle)
         w = self.width
         for o in self.data:
             itm = MenuItem(m)
             itm.applyStyle(self.itemStyle)
             itm.align = self.align
             itm.iconWidth = 0
             itm.header = koan.ToUnicode(o)
             try:
                 itm.enabled = o.enabled
             except:
                 pass
             itm.command = str(self.data.index(o))
             itm.width = w
             if o == self.data[self.index]:
                 itm.setFocus()
         m.xy = self.local2global(0, self.height)
         m.width = w
         ret = m.doModal()
         self.setFocus()            
         if type(ret) is str or type(ret) is unicode:
             try:
                 self.index = int(ret)
             except:
                 pass
Ejemplo n.º 33
0
 def __init__(self, parent, name, arg):
     logger.debug('AlbumTreeBranchMenu.__init__(parent=%r, name=%r, arg=%r)', parent, name, arg)
     MenuItem.__init__(self, name, parent=parent)
     self.parent = parent
     self.branch = arg[0]
     self.data = arg[1]
Ejemplo n.º 34
0
 def __init__(self, parent, tree):
     logger.debug('AlbumTreeMainMenu.__init__(parent=%r)', parent)
     MenuItem.__init__(self, name=_('Album Tree 2'), parent=parent, skin_type='album_tree', type='audio')
     self.parent = parent
     self.tree = tree
Ejemplo n.º 35
0
 def __init__(self, parent):
     MenuItem.__init__(self, parent, arg='audio', skin_type='radio')
     self.name = _('Video Podcast')
Ejemplo n.º 36
0
 def __init__(self, parent):
     MenuItem.__init__(self, parent, arg="audio", skin_type="radio")
     self.name = _("Audio Podcast")
Ejemplo n.º 37
0
 def __init__(self, parent):
     logger.log(9, "RadioMainMenuItem.__init__(parent=%r)", parent)
     MenuItem.__init__(self, parent, arg="audio", skin_type="radio")
     self.name = _("Radio")