How to use the khal.ui.widgets.ValidatedEdit function in khal

To help you get started, we’ve selected a few khal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pimutils / khal / khal / ui / widgets.py View on Github external
def __init__(self, dt):
        days, hours, minutes, seconds = self._convert_timedelta(dt)

        self.days_edit = ValidatedEdit(
            edit_text=str(days), validate=self.unsigned_int, align='right')
        self.hours_edit = ValidatedEdit(
            edit_text=str(hours), validate=self.unsigned_int, align='right')
        self.minutes_edit = ValidatedEdit(
            edit_text=str(minutes), validate=self.unsigned_int, align='right')
        self.seconds_edit = ValidatedEdit(
            edit_text=str(seconds), validate=self.unsigned_int, align='right')

        self.columns = NColumns([
            (4, self.days_edit),
            (2, urwid.Text('D')),
            (3, self.hours_edit),
            (2, urwid.Text('H')),
            (3, self.minutes_edit),
            (2, urwid.Text('M')),
            (3, self.seconds_edit),
            (2, urwid.Text('S')),
        ])

        urwid.WidgetWrap.__init__(self, self.columns)
github pimutils / khal / khal / ui / widgets.py View on Github external
def __init__(self, dt):
        days, hours, minutes, seconds = self._convert_timedelta(dt)

        self.days_edit = ValidatedEdit(
            edit_text=str(days), validate=self.unsigned_int, align='right')
        self.hours_edit = ValidatedEdit(
            edit_text=str(hours), validate=self.unsigned_int, align='right')
        self.minutes_edit = ValidatedEdit(
            edit_text=str(minutes), validate=self.unsigned_int, align='right')
        self.seconds_edit = ValidatedEdit(
            edit_text=str(seconds), validate=self.unsigned_int, align='right')

        self.columns = NColumns([
            (4, self.days_edit),
            (2, urwid.Text('D')),
            (3, self.hours_edit),
            (2, urwid.Text('H')),
            (3, self.minutes_edit),
            (2, urwid.Text('M')),
            (3, self.seconds_edit),
github pimutils / khal / khal / ui / widgets.py View on Github external
def __init__(self, dt):
        days, hours, minutes, seconds = self._convert_timedelta(dt)

        self.days_edit = ValidatedEdit(
            edit_text=str(days), validate=self.unsigned_int, align='right')
        self.hours_edit = ValidatedEdit(
            edit_text=str(hours), validate=self.unsigned_int, align='right')
        self.minutes_edit = ValidatedEdit(
            edit_text=str(minutes), validate=self.unsigned_int, align='right')
        self.seconds_edit = ValidatedEdit(
            edit_text=str(seconds), validate=self.unsigned_int, align='right')

        self.columns = NColumns([
            (4, self.days_edit),
            (2, urwid.Text('D')),
            (3, self.hours_edit),
            (2, urwid.Text('H')),
            (3, self.minutes_edit),
            (2, urwid.Text('M')),
            (3, self.seconds_edit),
            (2, urwid.Text('S')),
        ])

        urwid.WidgetWrap.__init__(self, self.columns)
github pimutils / khal / khal / ui / editor.py View on Github external
)
        self.widgets.enddate = DateEdit(
            self._enddt, self.conf['locale']['longdateformat'],
            self._end_date_change, self.conf['locale']['weeknumbers'],
            self.conf['locale']['firstweekday'],
            self.conf['view']['monthdisplay'],
            self.conf['keybindings'],
        )

        if state is True:
            timewidth = 1
            self.widgets.starttime = urwid.Text('')
            self.widgets.endtime = urwid.Text('')
        elif state is False:
            timewidth = self._timewidth + 1
            raw_start_time_widget = ValidatedEdit(
                dateformat=self.conf['locale']['timeformat'],
                EditWidget=TimeWidget,
                validate=self._validate_start_time,
                edit_text=self.startdt.strftime(self.conf['locale']['timeformat']),
            )
            self.widgets.starttime = urwid.Padding(
                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)
github pimutils / khal / khal / ui / editor.py View on Github external
if state is True:
            timewidth = 1
            self.widgets.starttime = urwid.Text('')
            self.widgets.endtime = urwid.Text('')
        elif state is False:
            timewidth = self._timewidth + 1
            raw_start_time_widget = ValidatedEdit(
                dateformat=self.conf['locale']['timeformat'],
                EditWidget=TimeWidget,
                validate=self._validate_start_time,
                edit_text=self.startdt.strftime(self.conf['locale']['timeformat']),
            )
            self.widgets.starttime = urwid.Padding(
                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)
github pimutils / khal / khal / ui / editor.py View on Github external
def __init__(
            self, startdt=None, dateformat='%Y-%m-%d',
            on_date_change=lambda _: None,
            weeknumbers=False, firstweekday=0, monthdisplay='firstday',
            keybindings=None,
    ):
        datewidth = len(startdt.strftime(dateformat)) + 1
        self._dateformat = dateformat
        if startdt is None:
            startdt = dt.date.today()
        self._edit = ValidatedEdit(
            dateformat=dateformat,
            EditWidget=DateWidget,
            validate=self._validate,
            edit_text=startdt.strftime(dateformat),
            on_date_change=on_date_change)
        wrapped = CalendarPopUp(self._edit, on_date_change, weeknumbers,
                                firstweekday, monthdisplay, keybindings)
        padded = urwid.Padding(wrapped, align='left', width=datewidth, left=0, right=1)
        super().__init__(padded)
github pimutils / khal / khal / ui / widgets.py View on Github external
def __init__(self, dt):
        days, hours, minutes, seconds = self._convert_timedelta(dt)

        self.days_edit = ValidatedEdit(
            edit_text=str(days), validate=self.unsigned_int, align='right')
        self.hours_edit = ValidatedEdit(
            edit_text=str(hours), validate=self.unsigned_int, align='right')
        self.minutes_edit = ValidatedEdit(
            edit_text=str(minutes), validate=self.unsigned_int, align='right')
        self.seconds_edit = ValidatedEdit(
            edit_text=str(seconds), validate=self.unsigned_int, align='right')

        self.columns = NColumns([
            (4, self.days_edit),
            (2, urwid.Text('D')),
            (3, self.hours_edit),
            (2, urwid.Text('H')),
            (3, self.minutes_edit),
            (2, urwid.Text('M')),
            (3, self.seconds_edit),
            (2, urwid.Text('S')),
        ])