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)))
|
||||
|
||||
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):
|
||||
if key in ['tab', 'n', 'N', 'j', 'J']:
|
||||
|
|
|
@ -50,8 +50,8 @@ class DiskPartitionView(BaseView):
|
|||
super().__init__(self.body)
|
||||
|
||||
def _build_buttons(self):
|
||||
cancel = cancel_btn(on_press=self.cancel)
|
||||
done = done_btn(on_press=self.done)
|
||||
cancel = cancel_btn(_("Cancel"), on_press=self.cancel)
|
||||
done = done_btn(_("Done"), on_press=self.done)
|
||||
|
||||
buttons = [
|
||||
done,
|
||||
|
|
|
@ -59,8 +59,8 @@ class FilesystemConfirmationView(WidgetWrap):
|
|||
pile = Pile([
|
||||
UrwidPadding(Text(confirmation_text), left=2, right=2),
|
||||
button_pile([
|
||||
cancel_btn(label=_("No"), on_press=self.cancel),
|
||||
danger_btn(on_press=self.ok)]),
|
||||
cancel_btn(_("No"), on_press=self.cancel),
|
||||
danger_btn(_("Continue"), on_press=self.ok)]),
|
||||
Text(""),
|
||||
])
|
||||
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
|
||||
if self.model.can_install():
|
||||
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(back_btn(on_press=self.cancel))
|
||||
buttons.append(reset_btn(_("Reset"), on_press=self.reset))
|
||||
buttons.append(back_btn(_("Back"), on_press=self.cancel))
|
||||
|
||||
return button_pile(buttons)
|
||||
|
||||
|
|
|
@ -39,9 +39,9 @@ class GuidedFilesystemView(BaseView):
|
|||
|
||||
def __init__(self, model, controller):
|
||||
self.controller = controller
|
||||
guided = ok_btn(label=_("Use An Entire Disk"), on_press=self.guided)
|
||||
manual = ok_btn(label=_("Manual"), on_press=self.manual)
|
||||
back = back_btn(on_press=self.cancel)
|
||||
guided = ok_btn(_("Use An Entire Disk"), on_press=self.guided)
|
||||
manual = ok_btn(_("Manual"), on_press=self.manual)
|
||||
back = back_btn(_("Back"), on_press=self.cancel)
|
||||
lb = ListBox([
|
||||
Padding.center_70(Text("")),
|
||||
Padding.center_70(Text(text)),
|
||||
|
@ -65,7 +65,7 @@ class GuidedDiskSelectionView(BaseView):
|
|||
def __init__(self, model, controller):
|
||||
self.model = model
|
||||
self.controller = controller
|
||||
cancel = cancel_btn(on_press=self.cancel)
|
||||
cancel = cancel_btn("Cancel", on_press=self.cancel)
|
||||
disks = []
|
||||
for disk in self.model.all_disks():
|
||||
disk_btn = menu_btn(
|
||||
|
|
|
@ -197,7 +197,7 @@ class PartitionView(PartitionFormatView):
|
|||
def make_body(self):
|
||||
body = super().make_body()
|
||||
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":
|
||||
btn = WidgetDisable(Color.info_minor(btn.original_widget))
|
||||
body.extend([
|
||||
|
|
|
@ -64,11 +64,11 @@ class ProgressView(BaseView):
|
|||
|
||||
def show_complete(self, include_exit=False):
|
||||
buttons = [
|
||||
ok_btn(label=_("Reboot Now"), on_press=self.reboot),
|
||||
ok_btn(_("Reboot Now"), on_press=self.reboot),
|
||||
]
|
||||
if include_exit:
|
||||
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)
|
||||
|
||||
new_pile = Pile([
|
||||
|
|
|
@ -15,33 +15,30 @@
|
|||
|
||||
from urwid import AttrMap, Button, Text
|
||||
|
||||
def _stylized_button(left, right, stocklabel, style):
|
||||
def _stylized_button(left, right, style):
|
||||
class Btn(Button):
|
||||
button_left = Text(left)
|
||||
button_right = Text(right)
|
||||
|
||||
class StyleAttrMap(AttrMap):
|
||||
def __init__(self, *args, **kwargs):
|
||||
label = kwargs.pop('label', _(stocklabel))
|
||||
btn = Btn(label, *args, **kwargs)
|
||||
def __init__(self, label, on_press=None, user_arg=None):
|
||||
btn = Btn(label, on_press=on_press, user_data=user_arg)
|
||||
super().__init__(btn, style + '_button', style + '_button focus')
|
||||
return StyleAttrMap
|
||||
|
||||
def stylized_button(stocklabel, style):
|
||||
return _stylized_button('[', ']', stocklabel, style)
|
||||
def action_button(style):
|
||||
return _stylized_button('[', ']', style)
|
||||
|
||||
def menu_btn(label, on_press=None, user_arg=None):
|
||||
MenuBtn=_stylized_button('', '>', label, 'menu')
|
||||
return MenuBtn(on_press=on_press, user_data=user_arg)
|
||||
menu_btn = _stylized_button("", ">", "menu")
|
||||
|
||||
ok_btn = stylized_button("OK", "save")
|
||||
done_btn = stylized_button("Done", "save")
|
||||
ok_btn = action_button("save")
|
||||
done_btn = action_button("save")
|
||||
|
||||
reset_btn = stylized_button("Reset", "reset")
|
||||
reset_btn = action_button("reset")
|
||||
|
||||
back_btn = stylized_button("Back", "cancel")
|
||||
cancel_btn = stylized_button("Cancel", "cancel")
|
||||
close_btn = stylized_button("Close", "cancel")
|
||||
back_btn = action_button("cancel")
|
||||
cancel_btn = action_button("cancel")
|
||||
close_btn = action_button("cancel")
|
||||
|
||||
danger_btn = stylized_button("Continue", "danger")
|
||||
delete_btn = stylized_button("Delete", "danger")
|
||||
danger_btn = action_button("danger")
|
||||
delete_btn = action_button("danger")
|
||||
|
|
|
@ -275,8 +275,8 @@ class Form(object, metaclass=MetaForm):
|
|||
ok_label = _("Done")
|
||||
|
||||
def __init__(self, initial={}):
|
||||
self.done_btn = Toggleable(done_btn(label=self.ok_label, on_press=self._click_done))
|
||||
self.cancel_btn = Toggleable(cancel_btn(on_press=self._click_cancel))
|
||||
self.done_btn = Toggleable(done_btn(self.ok_label, on_press=self._click_done))
|
||||
self.cancel_btn = Toggleable(cancel_btn(_("Cancel"), on_press=self._click_cancel))
|
||||
self.buttons = button_pile([self.done_btn, self.cancel_btn])
|
||||
self._fields = []
|
||||
for field in self._unbound_fields:
|
||||
|
|
|
@ -42,7 +42,7 @@ class ApplyingConfigWidget(WidgetWrap):
|
|||
|
||||
def __init__(self, step_count, 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',
|
||||
complete='progress_complete',
|
||||
current=0, done=step_count)
|
||||
|
@ -134,8 +134,8 @@ class NetworkView(BaseView):
|
|||
super().__init__(self.frame)
|
||||
|
||||
def _build_buttons(self):
|
||||
back = back_btn(on_press=self.cancel)
|
||||
done = done_btn(on_press=self.done)
|
||||
back = back_btn(_("Back"), on_press=self.cancel)
|
||||
done = done_btn(_("Done"), on_press=self.done)
|
||||
|
||||
buttons = button_pile([done, back])
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ class NetworkConfigureInterfaceView(BaseView):
|
|||
|
||||
def _build_buttons(self):
|
||||
buttons = [
|
||||
done_btn(on_press=self.done)
|
||||
done_btn(_("Done"), on_press=self.done)
|
||||
]
|
||||
return button_pile(buttons)
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class NetworkList(WidgetWrap):
|
|||
|
||||
def __init__(self, parent, ssids):
|
||||
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]
|
||||
p = Pile([BoxAdapter(ListBox(ssid_list), height=10), Padding.fixed_10(button)])
|
||||
box = LineBox(p, title="Select a network")
|
||||
|
|
Loading…
Reference in New Issue