# Path: conjureup/ui/widgets/selectors.py
# class MenuSelectButtonList(SelectList):
#     option_type = ValuedMenuSelectButton
#     wrapable = True
# 
#     def __init__(self, opts=None, default=None, *args, **kwargs):
#         super().__init__(opts, *args, **kwargs)
#         if default:
#             self.select_item_by_value(default)
#         else:
#             self.select_first()


from collections import defaultdict
from ubuntui.utils import Color, Padding
from ubuntui.widgets.hr import HR
from urwid import Text
from conjureup.ui.views.base import BaseView
from conjureup.ui.widgets.selectors import MenuSelectButtonList
        if len(self.controllers) > 0:
            if self.app.jaas_ok:
                widget.append(HR())
            widget.append(Color.label(Text(
                "Existing Self-Hosted Controllers")))
            widget.append(Padding.line_break(""))
            cdict = defaultdict(lambda: defaultdict(list))
            for cname, d in self.controllers.items():
                cdict[d['cloud']][d.get('region', None)].append((cname, d))

            for cloudname, cloud_d in sorted(cdict.items()):
                widget.append(Color.label(Text("  {}".format(cloudname))))
                for regionname, controllers in cloud_d.items():
                    for controller_name, controller in sorted(controllers):
                        label = "    {}".format(controller_name)
                        if regionname:
                            label += " ({})".format(regionname)
                        widget.append_option(
                            label,
                            controller_name,
                            enabled=controller.get('api-endpoints'))
                widget.append(Padding.line_break(""))
            widget.append(Padding.line_break(""))
        widget.append(HR())
        widget.append_option("Deploy New Self-Hosted Controller", None)
        widget.select_first()
        return widget

    def after_keypress(self):
        selected = self.widget.selected_widgets

# Path: conjureup/ui/widgets/selectors.py
# class MenuSelectButtonList(SelectList):
#     option_type = ValuedMenuSelectButton
#     wrapable = True
# 
#     def __init__(self, opts=None, default=None, *args, **kwargs):
#         super().__init__(opts, *args, **kwargs)
#         if default:
#             self.select_item_by_value(default)
#         else:
#             self.select_first()


# Path: conjureup/ui/views/ControllerListView.py
from collections import defaultdict
from ubuntui.utils import Color, Padding
from ubuntui.widgets.hr import HR
from urwid import Text
from conjureup.ui.views.base import BaseView
from conjureup.ui.widgets.selectors import MenuSelectButtonList

        if len(self.controllers) > 0:
            if self.app.jaas_ok:
                widget.append(HR())
            widget.append(Color.label(Text(
                "Existing Self-Hosted Controllers")))
            widget.append(Padding.line_break(""))
            cdict = defaultdict(lambda: defaultdict(list))
            for cname, d in self.controllers.items():
                cdict[d['cloud']][d.get('region', None)].append((cname, d))

            for cloudname, cloud_d in sorted(cdict.items()):
                widget.append(Color.label(Text("  {}".format(cloudname))))
                for regionname, controllers in cloud_d.items():
                    for controller_name, controller in sorted(controllers):
                        label = "    {}".format(controller_name)
                        if regionname:
                            label += " ({})".format(regionname)
                        widget.append_option(
                            label,
                            controller_name,
                            enabled=controller.get('api-endpoints'))
                widget.append(Padding.line_break(""))
            widget.append(Padding.line_break(""))
        widget.append(HR())
        widget.append_option("Deploy New Self-Hosted Controller", None)
        widget.select_first()
        return widget

    def after_keypress(self):
        selected = self.widget.selected_widgets

        if selected is None: