Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _rebuild_edit(self):
firstline = NColumns([
(13, self.repeat_box),
(11, self.recurrence_choice),
(11, self.interval_edit),
])
lines = [firstline]
if self.recurrence_choice.active == "weekly":
lines.append(self.weekday_checks)
if self.recurrence_choice.active == "monthly":
lines.append(self.monthly_choice)
nextline = [(16, self.until_choice)]
if self.until_choice.active == "Until":
nextline.append((20, self.until_edit))
elif self.until_choice.active == "Repetitions":
nextline.append((4, self.repetitions_edit))
raw_start_time_widget, align='left', width=self._timewidth + 1, left=1)
raw_end_time_widget = ValidatedEdit(
dateformat=self.conf['locale']['timeformat'],
EditWidget=TimeWidget,
validate=self._validate_end_time,
edit_text=self.enddt.strftime(self.conf['locale']['timeformat']),
)
self.widgets.endtime = urwid.Padding(
raw_end_time_widget, align='left', width=self._timewidth + 1, left=1)
columns = NPile([
self.checkallday,
NColumns([(5, urwid.Text('From:')), (self._datewidth, self.widgets.startdate), (
timewidth, self.widgets.starttime)], dividechars=1),
NColumns(
[(5, urwid.Text('To:')), (self._datewidth, self.widgets.enddate),
(timewidth, self.widgets.endtime)],
dividechars=1)
], focus_item=1)
urwid.WidgetWrap.__init__(self, columns)
def scrollable_dialog(self, text, buttons=None, title="Press `ESC` to close this window"):
"""Open a scrollable dialog box.
:param text: Text to appear as the body of the Dialog box
:type text: str
:param buttons: list of tuples of button labels and functions to call
when the button is pressed
:type buttons: list(str, callable)
"""
body = urwid.ListBox([urwid.Text(line) for line in text.splitlines()])
if buttons:
buttons = NColumns(
[urwid.Button(label, on_press=func) for label, func in buttons],
outermost=True,
)
content = urwid.LineBox(urwid.Pile([body, ('pack', buttons)]))
else:
content = urwid.LineBox(urwid.Pile([body]))
# put the title on the upper line
over = urwid.Overlay(
urwid.Text(" " + title + " "), content, 'center', len(title) + 2, 'top', None,
)
overlay = urwid.Overlay(
over, self, 'center', ('relative', 70), 'middle', ('relative', 70), None)
self.window.open(overlay)
calendar = CalendarWidget(
on_date_change=self.eventscolumn.original_widget.set_focus_date,
keybindings=self._conf['keybindings'],
on_press={key: self.new_event for key in self._conf['keybindings']['new']},
firstweekday=self._conf['locale']['firstweekday'],
weeknumbers=self._conf['locale']['weeknumbers'],
monthdisplay=self._conf['view']['monthdisplay'],
get_styles=collection.get_styles
)
if self._conf['view']['dynamic_days']:
elistbox.set_focus_date_callback = calendar.set_focus_date
else:
elistbox.set_focus_date_callback = lambda _: None
self.calendar = ContainerWidget(calendar)
self.lwidth = 31 if self._conf['locale']['weeknumbers'] == 'right' else 28
columns = NColumns(
[(self.lwidth, self.calendar), self.eventscolumn],
dividechars=0,
box_columns=[0, 1],
outermost=True,
)
Pane.__init__(self, columns, title=title, description=description)
def _rebuild_edit_no_repeat(self):
lines = [NColumns([(13, self.repeat_box)])]
self._refill_contents(lines)
def __init__(self, startdt, selected_days):
self._weekday_boxes = {day: urwid.CheckBox(day, state=False) for day in WEEKDAYS}
weekday = startdt.weekday()
self._weekday_boxes[WEEKDAYS[weekday]].state = True
self.weekday_checks = NColumns([(7, self._weekday_boxes[wd]) for wd in WEEKDAYS])
for day in selected_days:
self._weekday_boxes[day].state = True
urwid.WidgetWrap.__init__(self, self.weekday_checks)
def keypress(self, size, key):
if key == 'enter':
search_func(self.text)
else:
return super().keypress(size, key)
search_field = Search('')
def this_func(_):
search_func(search_field.text)
lines = []
lines.append(urwid.Text('Please enter a search term (Escape cancels):'))
lines.append(search_field)
buttons = NColumns([urwid.Button('Search', on_press=this_func),
urwid.Button('Abort', on_press=abort_func)])
lines.append(buttons)
content = NPile(lines, outermost=True)
urwid.WidgetWrap.__init__(self, urwid.LineBox(content))