stop any of the *_btn functions defining a label by default
This commit is contained in:
parent
26147d3cc3
commit
c85602527e
|
@ -39,7 +39,7 @@ class DiskInfoView(BaseView):
|
||||||
super().__init__(Padding.center_79(SimpleList(body)))
|
super().__init__(Padding.center_79(SimpleList(body)))
|
||||||
|
|
||||||
def _build_buttons(self):
|
def _build_buttons(self):
|
||||||
return button_pile([done_btn(on_press=self.done)])
|
return button_pile([done_btn(_("Done"), on_press=self.done)])
|
||||||
|
|
||||||
def keypress(self, size, key):
|
def keypress(self, size, key):
|
||||||
if key in ['tab', 'n', 'N', 'j', 'J']:
|
if key in ['tab', 'n', 'N', 'j', 'J']:
|
||||||
|
|
|
@ -50,8 +50,8 @@ class DiskPartitionView(BaseView):
|
||||||
super().__init__(self.body)
|
super().__init__(self.body)
|
||||||
|
|
||||||
def _build_buttons(self):
|
def _build_buttons(self):
|
||||||
cancel = cancel_btn(on_press=self.cancel)
|
cancel = cancel_btn(_("Cancel"), on_press=self.cancel)
|
||||||
done = done_btn(on_press=self.done)
|
done = done_btn(_("Done"), on_press=self.done)
|
||||||
|
|
||||||
buttons = [
|
buttons = [
|
||||||
done,
|
done,
|
||||||
|
|
|
@ -59,8 +59,8 @@ class FilesystemConfirmationView(WidgetWrap):
|
||||||
pile = Pile([
|
pile = Pile([
|
||||||
UrwidPadding(Text(confirmation_text), left=2, right=2),
|
UrwidPadding(Text(confirmation_text), left=2, right=2),
|
||||||
button_pile([
|
button_pile([
|
||||||
cancel_btn(label=_("No"), on_press=self.cancel),
|
cancel_btn(_("No"), on_press=self.cancel),
|
||||||
danger_btn(on_press=self.ok)]),
|
danger_btn(_("Continue"), on_press=self.ok)]),
|
||||||
Text(""),
|
Text(""),
|
||||||
])
|
])
|
||||||
lb = LineBox(pile, title=_("Confirm destructive action"))
|
lb = LineBox(pile, title=_("Confirm destructive action"))
|
||||||
|
@ -150,10 +150,10 @@ class FilesystemView(BaseView):
|
||||||
# XXX should enable/disable button rather than having it appear/disappear I think
|
# XXX should enable/disable button rather than having it appear/disappear I think
|
||||||
if self.model.can_install():
|
if self.model.can_install():
|
||||||
buttons.append(
|
buttons.append(
|
||||||
done_btn(on_press=self.done))
|
done_btn(_("Done"), on_press=self.done))
|
||||||
|
|
||||||
buttons.append(reset_btn(on_press=self.reset))
|
buttons.append(reset_btn(_("Reset"), on_press=self.reset))
|
||||||
buttons.append(back_btn(on_press=self.cancel))
|
buttons.append(back_btn(_("Back"), on_press=self.cancel))
|
||||||
|
|
||||||
return button_pile(buttons)
|
return button_pile(buttons)
|
||||||
|
|
||||||
|
|
|
@ -39,9 +39,9 @@ class GuidedFilesystemView(BaseView):
|
||||||
|
|
||||||
def __init__(self, model, controller):
|
def __init__(self, model, controller):
|
||||||
self.controller = controller
|
self.controller = controller
|
||||||
guided = ok_btn(label=_("Use An Entire Disk"), on_press=self.guided)
|
guided = ok_btn(_("Use An Entire Disk"), on_press=self.guided)
|
||||||
manual = ok_btn(label=_("Manual"), on_press=self.manual)
|
manual = ok_btn(_("Manual"), on_press=self.manual)
|
||||||
back = back_btn(on_press=self.cancel)
|
back = back_btn(_("Back"), on_press=self.cancel)
|
||||||
lb = ListBox([
|
lb = ListBox([
|
||||||
Padding.center_70(Text("")),
|
Padding.center_70(Text("")),
|
||||||
Padding.center_70(Text(text)),
|
Padding.center_70(Text(text)),
|
||||||
|
@ -65,7 +65,7 @@ class GuidedDiskSelectionView(BaseView):
|
||||||
def __init__(self, model, controller):
|
def __init__(self, model, controller):
|
||||||
self.model = model
|
self.model = model
|
||||||
self.controller = controller
|
self.controller = controller
|
||||||
cancel = cancel_btn(on_press=self.cancel)
|
cancel = cancel_btn("Cancel", on_press=self.cancel)
|
||||||
disks = []
|
disks = []
|
||||||
for disk in self.model.all_disks():
|
for disk in self.model.all_disks():
|
||||||
disk_btn = menu_btn(
|
disk_btn = menu_btn(
|
||||||
|
|
|
@ -197,7 +197,7 @@ class PartitionView(PartitionFormatView):
|
||||||
def make_body(self):
|
def make_body(self):
|
||||||
body = super().make_body()
|
body = super().make_body()
|
||||||
if self.partition is not None:
|
if self.partition is not None:
|
||||||
btn = delete_btn(on_press=self.delete)
|
btn = delete_btn(_("Delete"), on_press=self.delete)
|
||||||
if self.partition.flag == "boot":
|
if self.partition.flag == "boot":
|
||||||
btn = WidgetDisable(Color.info_minor(btn.original_widget))
|
btn = WidgetDisable(Color.info_minor(btn.original_widget))
|
||||||
body.extend([
|
body.extend([
|
||||||
|
|
|
@ -64,11 +64,11 @@ class ProgressView(BaseView):
|
||||||
|
|
||||||
def show_complete(self, include_exit=False):
|
def show_complete(self, include_exit=False):
|
||||||
buttons = [
|
buttons = [
|
||||||
ok_btn(label=_("Reboot Now"), on_press=self.reboot),
|
ok_btn(_("Reboot Now"), on_press=self.reboot),
|
||||||
]
|
]
|
||||||
if include_exit:
|
if include_exit:
|
||||||
buttons.append(
|
buttons.append(
|
||||||
cancel_btn(label=_("Exit To Shell"), on_press=self.quit))
|
cancel_btn(_("Exit To Shell"), on_press=self.quit))
|
||||||
buttons = button_pile(buttons)
|
buttons = button_pile(buttons)
|
||||||
|
|
||||||
new_pile = Pile([
|
new_pile = Pile([
|
||||||
|
|
|
@ -15,33 +15,30 @@
|
||||||
|
|
||||||
from urwid import AttrMap, Button, Text
|
from urwid import AttrMap, Button, Text
|
||||||
|
|
||||||
def _stylized_button(left, right, stocklabel, style):
|
def _stylized_button(left, right, style):
|
||||||
class Btn(Button):
|
class Btn(Button):
|
||||||
button_left = Text(left)
|
button_left = Text(left)
|
||||||
button_right = Text(right)
|
button_right = Text(right)
|
||||||
|
|
||||||
class StyleAttrMap(AttrMap):
|
class StyleAttrMap(AttrMap):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, label, on_press=None, user_arg=None):
|
||||||
label = kwargs.pop('label', _(stocklabel))
|
btn = Btn(label, on_press=on_press, user_data=user_arg)
|
||||||
btn = Btn(label, *args, **kwargs)
|
|
||||||
super().__init__(btn, style + '_button', style + '_button focus')
|
super().__init__(btn, style + '_button', style + '_button focus')
|
||||||
return StyleAttrMap
|
return StyleAttrMap
|
||||||
|
|
||||||
def stylized_button(stocklabel, style):
|
def action_button(style):
|
||||||
return _stylized_button('[', ']', stocklabel, style)
|
return _stylized_button('[', ']', style)
|
||||||
|
|
||||||
def menu_btn(label, on_press=None, user_arg=None):
|
menu_btn = _stylized_button("", ">", "menu")
|
||||||
MenuBtn=_stylized_button('', '>', label, 'menu')
|
|
||||||
return MenuBtn(on_press=on_press, user_data=user_arg)
|
|
||||||
|
|
||||||
ok_btn = stylized_button("OK", "save")
|
ok_btn = action_button("save")
|
||||||
done_btn = stylized_button("Done", "save")
|
done_btn = action_button("save")
|
||||||
|
|
||||||
reset_btn = stylized_button("Reset", "reset")
|
reset_btn = action_button("reset")
|
||||||
|
|
||||||
back_btn = stylized_button("Back", "cancel")
|
back_btn = action_button("cancel")
|
||||||
cancel_btn = stylized_button("Cancel", "cancel")
|
cancel_btn = action_button("cancel")
|
||||||
close_btn = stylized_button("Close", "cancel")
|
close_btn = action_button("cancel")
|
||||||
|
|
||||||
danger_btn = stylized_button("Continue", "danger")
|
danger_btn = action_button("danger")
|
||||||
delete_btn = stylized_button("Delete", "danger")
|
delete_btn = action_button("danger")
|
||||||
|
|
|
@ -275,8 +275,8 @@ class Form(object, metaclass=MetaForm):
|
||||||
ok_label = _("Done")
|
ok_label = _("Done")
|
||||||
|
|
||||||
def __init__(self, initial={}):
|
def __init__(self, initial={}):
|
||||||
self.done_btn = Toggleable(done_btn(label=self.ok_label, on_press=self._click_done))
|
self.done_btn = Toggleable(done_btn(self.ok_label, on_press=self._click_done))
|
||||||
self.cancel_btn = Toggleable(cancel_btn(on_press=self._click_cancel))
|
self.cancel_btn = Toggleable(cancel_btn(_("Cancel"), on_press=self._click_cancel))
|
||||||
self.buttons = button_pile([self.done_btn, self.cancel_btn])
|
self.buttons = button_pile([self.done_btn, self.cancel_btn])
|
||||||
self._fields = []
|
self._fields = []
|
||||||
for field in self._unbound_fields:
|
for field in self._unbound_fields:
|
||||||
|
|
|
@ -42,7 +42,7 @@ class ApplyingConfigWidget(WidgetWrap):
|
||||||
|
|
||||||
def __init__(self, step_count, cancel_func):
|
def __init__(self, step_count, cancel_func):
|
||||||
self.cancel_func = cancel_func
|
self.cancel_func = cancel_func
|
||||||
button = cancel_btn(on_press=self.do_cancel)
|
button = cancel_btn(_("Cancel"), on_press=self.do_cancel)
|
||||||
self.bar = ProgressBar(normal='progress_incomplete',
|
self.bar = ProgressBar(normal='progress_incomplete',
|
||||||
complete='progress_complete',
|
complete='progress_complete',
|
||||||
current=0, done=step_count)
|
current=0, done=step_count)
|
||||||
|
@ -134,8 +134,8 @@ class NetworkView(BaseView):
|
||||||
super().__init__(self.frame)
|
super().__init__(self.frame)
|
||||||
|
|
||||||
def _build_buttons(self):
|
def _build_buttons(self):
|
||||||
back = back_btn(on_press=self.cancel)
|
back = back_btn(_("Back"), on_press=self.cancel)
|
||||||
done = done_btn(on_press=self.done)
|
done = done_btn(_("Done"), on_press=self.done)
|
||||||
|
|
||||||
buttons = button_pile([done, back])
|
buttons = button_pile([done, back])
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,7 @@ class NetworkConfigureInterfaceView(BaseView):
|
||||||
|
|
||||||
def _build_buttons(self):
|
def _build_buttons(self):
|
||||||
buttons = [
|
buttons = [
|
||||||
done_btn(on_press=self.done)
|
done_btn(_("Done"), on_press=self.done)
|
||||||
]
|
]
|
||||||
return button_pile(buttons)
|
return button_pile(buttons)
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ class NetworkList(WidgetWrap):
|
||||||
|
|
||||||
def __init__(self, parent, ssids):
|
def __init__(self, parent, ssids):
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
button = cancel_btn(on_press=self.do_cancel)
|
button = cancel_btn(_("Cancel"), on_press=self.do_cancel)
|
||||||
ssid_list = [menu_btn(label=ssid, on_press=self.do_network) for ssid in ssids]
|
ssid_list = [menu_btn(label=ssid, on_press=self.do_network) for ssid in ssids]
|
||||||
p = Pile([BoxAdapter(ListBox(ssid_list), height=10), Padding.fixed_10(button)])
|
p = Pile([BoxAdapter(ListBox(ssid_list), height=10), Padding.fixed_10(button)])
|
||||||
box = LineBox(p, title="Select a network")
|
box = LineBox(p, title="Select a network")
|
||||||
|
|
Loading…
Reference in New Issue