Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def render(self, size, focus):
if focus:
self.body[0].set_attr_map({None: 'date header focused'})
elif DateListBox.selected_date == self.date:
self.body[0].set_attr_map({None: 'date header selected'})
else:
self.reset_style()
return super().render(size, focus)
def render(self, a, focus):
if focus:
DateListBox.selected_date = None
return super().render(a, focus)
def render(self, a, focus):
if focus:
DateListBox.selected_date = None
return super().render(a, focus)
self.parent.calendar.base_widget.set_focus_date(dt.date.today())
rval = super().keypress(size, key)
self.clean()
if key in ['up', 'down']:
try:
self._old_focus = self.focus_position
except IndexError:
pass
day = self.body[self.body.focus].date
# we need to save DateListBox.selected_date and reset it later, because
# calling CalendarWalker.set_focus_date() calls back into
# DayWalker().update_by_date() which actually sets selected_date
# that's why it's called callback hell...
currently_selected_date = DateListBox.selected_date
self.set_focus_date_callback(day) # TODO convert to callback
DateListBox.selected_date = currently_selected_date
return rval
def set_selected_date(self, day):
"""Mark `day` as selected
:param day: day to mark as selected
:type day: datetime.date
"""
DateListBox.selected_date = day
# we need to touch the title's content to make sure
# that urwid re-renders the title
title = self.body[0].original_widget
title.set_text(title.get_text()[0])
def set_selected_date(self, day):
"""Mark `day` as selected
:param day: day to mark as selected
:type day: datetime.date
"""
DateListBox.selected_date = day
# we need to touch the title's content to make sure
# that urwid re-renders the title
title = self.body[0].original_widget
title.set_text(title.get_text()[0])
self.parent.calendar.base_widget.set_focus_date(dt.date.today())
rval = super().keypress(size, key)
self.clean()
if key in ['up', 'down']:
try:
self._old_focus = self.focus_position
except IndexError:
pass
day = self.body[self.body.focus].date
# we need to save DateListBox.selected_date and reset it later, because
# calling CalendarWalker.set_focus_date() calls back into
# DayWalker().update_by_date() which actually sets selected_date
# that's why it's called callback hell...
currently_selected_date = DateListBox.selected_date
self.set_focus_date_callback(day) # TODO convert to callback
DateListBox.selected_date = currently_selected_date
return rval
rval = super().keypress(size, key)
self.clean()
if key in ['up', 'down']:
try:
self._old_focus = self.focus_position
except IndexError:
pass
day = self.body[self.body.focus].date
# we need to save DateListBox.selected_date and reset it later, because
# calling CalendarWalker.set_focus_date() calls back into
# DayWalker().update_by_date() which actually sets selected_date
# that's why it's called callback hell...
currently_selected_date = DateListBox.selected_date
self.set_focus_date_callback(day) # TODO convert to callback
DateListBox.selected_date = currently_selected_date
return rval
def render(self, size, focus):
if focus:
self.body[0].set_attr_map({None: 'date header focused'})
elif DateListBox.selected_date == self.date:
self.body[0].set_attr_map({None: 'date header selected'})
else:
self.reset_style()
return super().render(size, focus)
rval = super().keypress(size, key)
self.clean()
if key in ['up', 'down']:
try:
self._old_focus = self.focus_position
except IndexError:
pass
day = self.body[self.body.focus].date
# we need to save DateListBox.selected_date and reset it later, because
# calling CalendarWalker.set_focus_date() calls back into
# DayWalker().update_by_date() which actually sets selected_date
# that's why it's called callback hell...
currently_selected_date = DateListBox.selected_date
self.set_focus_date_callback(day) # TODO convert to callback
DateListBox.selected_date = currently_selected_date
return rval