Кажется, что библиотека Python urwid
не включает в себя средство выбора даты (состояние 2018). Поэтому я написал (элементарный) один.
Класс называется additional_urwid_widgets.DatePicker
, и может быть установлен через пункт .
Для автономного примера , который иллюстрирует функциональность виджета, см. здесь .
Дополнительные (и более простые) примеры см. здесь .
Более подробное подробное объяснение параметров и опций смотрите в соответствующей записи вики-сайта github .
Некоторые примеры
Minimal
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
from additional_urwid_widgets import DatePicker, MODIFIER_KEY # installed via pip
import urwid # installed via pip
# Color schemes that specify the appearance off focus and on focus.
PALETTE = [("reveal_focus", "black", "white")]
dp = DatePicker(highlight_prop=("reveal_focus", None)) # By default, the focused picker is not highlighted!
pile = urwid.Pile([urwid.Text("press additionally the key modifier (default is 'ctrl')."),
urwid.Divider(" "),
dp])
loop = urwid.MainLoop(urwid.Filler(pile, "top"),
PALETTE)
loop.run()
Не сегодня
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
import datetime
from additional_urwid_widgets import DatePicker, MODIFIER_KEY # installed via pip
import urwid # installed via pip
# Color schemes that specify the appearance off focus and on focus.
PALETTE = [("reveal_focus", "black", "white")]
not_today = datetime.date(2018, 2, 20)
dp = DatePicker(initial_date=not_today,
highlight_prop=("reveal_focus", None)) # By default, the focused picker is not highlighted!
pile = urwid.Pile([urwid.Text("press additionally the key modifier (default is 'ctrl')."),
urwid.Divider(" "),
dp])
loop = urwid.MainLoop(urwid.Filler(pile, "top"),
PALETTE)
loop.run()
ISO-8601 + Styled + Compact
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
import calendar
from additional_urwid_widgets import DatePicker, MODIFIER_KEY # installed via pip
import urwid # installed via pip
# Color schemes that specify the appearance off focus and on focus.
PALETTE = [("dp_barActive_focus", "light gray", ""),
("dp_barActive_offFocus", "black", ""),
("dp_barInactive_focus", "dark gray", ""),
("dp_barInactive_offFocus", "black", ""),
("dp_highlight_focus", "black", "brown", "standout"),
("dp_highlight_offFocus", "white", "black")]
dp = DatePicker(month_names=[str(i).zfill(2) for i in range(13)],
day_format=[DatePicker.DAY_FORMAT.DAY_OF_MONTH_TWO_DIGIT],
columns=((6, DatePicker.PICKER.YEAR), (4, DatePicker.PICKER.MONTH), (4, DatePicker.PICKER.DAY)),
min_width_each_picker=4,
space_between=1,
topBar_endCovered_prop=("ᐃ", "dp_barActive_focus", "dp_barActive_offFocus"),
topBar_endExposed_prop=("───", "dp_barInactive_focus", "dp_barInactive_offFocus"),
bottomBar_endCovered_prop=("ᐁ", "dp_barActive_focus", "dp_barActive_offFocus"),
bottomBar_endExposed_prop=("───", "dp_barInactive_focus", "dp_barInactive_offFocus"),
highlight_prop=("dp_highlight_focus", "dp_highlight_offFocus"))
pile = urwid.Pile([urwid.Text("press additionally the key modifier (default is 'ctrl')."),
urwid.Divider(" "),
dp])
loop = urwid.MainLoop(urwid.Filler(pile, "top"),
PALETTE)
loop.run()