How to use the khal.ui.widgets.NPile 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 / editor.py View on Github external
until = self._startdt.date()
        elif until is None:
            until = self._startdt

        if isinstance(until, dt.datetime):
            until = until.date()
        self.until_edit = DateEdit(
            until, self._conf['locale']['longdateformat'],
            lambda _: None, self._conf['locale']['weeknumbers'],
            self._conf['locale']['firstweekday'],
            self._conf['view']['monthdisplay'],
        )

        self._rebuild_weekday_checks()
        self._rebuild_monthly_choice()
        self._pile = pile = NPile([urwid.Text('')])
        urwid.WidgetWrap.__init__(self, pile)
        self.rebuild()
github pimutils / khal / khal / ui / editor.py View on Github external
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)
        ], focus_item=1)
        urwid.WidgetWrap.__init__(self, columns)
github pimutils / khal / khal / ui / widgets.py View on Github external
def __init__(self, parent):
        self.parent = parent
        self._edit = ExtendedEdit('', parent.active)
        urwid.connect_signal(self._edit, 'change',
                             lambda edit, text: self.filter(text))
        self._walker = urwid.SimpleFocusListWalker([self._edit])
        walker = urwid.BoxAdapter(
            urwid.ListBox(self._walker), height=self.parent.win_len - 1)
        self._pile = NPile([self._edit, walker], outermost=True)
        self.filter('')
        self.focus_on(self.parent.active)
        fill = urwid.Filler(self._pile, 'top')
        urwid.WidgetWrap.__init__(self, urwid.AttrMap(fill, 'popupbg'))
github pimutils / khal / khal / ui / editor.py View on Github external
def __init__(self, this_func, abort_func, event):
        lines = []
        lines.append(urwid.Text('Export event as ICS file'))
        lines.append(urwid.Text(''))
        export_location = ExtendedEdit(
            caption='Location: ', edit_text="~/%s.ics" % event.summary.strip())
        lines.append(export_location)
        lines.append(urwid.Divider(' '))
        lines.append(
            urwid.Button('Save', on_press=this_func, user_data=export_location)
        )
        content = NPile(lines)
        urwid.WidgetWrap.__init__(self, urwid.LineBox(content))
github pimutils / khal / khal / ui / widgets.py View on Github external
def __init__(self, event):
        self.event = event

        self.pile = NPile(
            [urwid.Text('Alarms:')] +
            [self.AlarmEditor(a, self.remove_alarm) for a in event.alarms] +
            [urwid.Columns([(12, urwid.Button('Add', on_press=self.add_alarm))])])

        urwid.WidgetWrap.__init__(self, self.pile)
github pimutils / khal / khal / ui / __init__.py View on Github external
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))
github pimutils / khal / khal / ui / widgets.py View on Github external
def __init__(self, parent):
        self.parent = parent
        buttons = []
        for c in parent.choices:
            buttons.append(
                urwid.Button(parent._decorate(c),
                             on_press=self.set_choice, user_data=c)
            )

        pile = NPile(buttons, outermost=True)
        num = [num for num, elem in enumerate(parent.choices) if elem == parent.active][0]
        pile.set_focus(num)
        fill = urwid.Filler(pile)
        urwid.WidgetWrap.__init__(self, urwid.AttrMap(fill, 'popupbg'))
github pimutils / khal / khal / ui / __init__.py View on Github external
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))