2017-09-15 20:47:12 +00:00
|
|
|
# Copyright 2017 Canonical, Ltd.
|
2015-06-10 20:59:55 +00:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
# License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2017-09-15 20:47:12 +00:00
|
|
|
from urwid import AttrMap, Button, Text
|
2015-06-10 20:59:55 +00:00
|
|
|
|
2017-11-22 00:26:55 +00:00
|
|
|
def _stylized_button(left, right, style):
|
2017-09-15 20:47:12 +00:00
|
|
|
class Btn(Button):
|
|
|
|
button_left = Text(left)
|
|
|
|
button_right = Text(right)
|
2015-08-24 15:51:10 +00:00
|
|
|
|
2017-09-15 20:47:12 +00:00
|
|
|
class StyleAttrMap(AttrMap):
|
2017-11-22 00:26:55 +00:00
|
|
|
def __init__(self, label, on_press=None, user_arg=None):
|
|
|
|
btn = Btn(label, on_press=on_press, user_data=user_arg)
|
2017-09-15 20:47:12 +00:00
|
|
|
super().__init__(btn, style + '_button', style + '_button focus')
|
|
|
|
return StyleAttrMap
|
2015-08-24 15:51:10 +00:00
|
|
|
|
2017-11-22 00:26:55 +00:00
|
|
|
def action_button(style):
|
|
|
|
return _stylized_button('[', ']', style)
|
2015-08-24 15:51:10 +00:00
|
|
|
|
2017-11-22 00:26:55 +00:00
|
|
|
menu_btn = _stylized_button("", ">", "menu")
|
2017-11-23 22:19:01 +00:00
|
|
|
forward_btn = _stylized_button("", ">", "done")
|
2017-11-22 00:28:08 +00:00
|
|
|
done_btn = action_button("done")
|
|
|
|
danger_btn = action_button("danger")
|
|
|
|
other_btn = action_button("other")
|
2017-09-14 23:04:38 +00:00
|
|
|
|
2017-11-22 00:28:08 +00:00
|
|
|
ok_btn = done_btn
|
2017-09-14 23:04:38 +00:00
|
|
|
|
2017-11-22 00:28:08 +00:00
|
|
|
delete_btn = danger_btn
|
|
|
|
|
|
|
|
back_btn = other_btn
|
|
|
|
cancel_btn = other_btn
|
|
|
|
reset_btn = other_btn
|
2017-09-14 02:51:56 +00:00
|
|
|
|
|
|
|
|