def __init__(self, title, topics): button_widgets = [] ok_button = mywid.FixedButton('OK') cancel_button = mywid.FixedButton('Cancel') urwid.connect_signal(ok_button, 'click', lambda button: self._emit('ok')) urwid.connect_signal(cancel_button, 'click', lambda button: self._emit('cancel')) button_widgets.append(('pack', ok_button)) button_widgets.append(('pack', cancel_button)) button_columns = urwid.Columns(button_widgets, dividechars=2) self.topic_buttons = [] self.topic_keys = {} rows = [] for key, name in topics: button = mywid.FixedRadioButton(self.topic_buttons, name) self.topic_keys[button] = key rows.append(button) rows.append(urwid.Divider()) rows.append(button_columns) pile = urwid.Pile(rows) fill = urwid.Filler(pile, valign='top') super(TopicSelectDialog, self).__init__(urwid.LineBox(fill, title))
def __init__(self, change): save_button = mywid.FixedButton('Propose Change') cancel_button = mywid.FixedButton('Cancel') urwid.connect_signal(save_button, 'click', lambda button: self._emit('save')) urwid.connect_signal(cancel_button, 'click', lambda button: self._emit('cancel')) button_widgets = [('pack', save_button), ('pack', cancel_button)] button_columns = urwid.Columns(button_widgets, dividechars=2) rows = [] self.entry = urwid.Edit(edit_text=change.revisions[-1].message, multiline=True) self.branch_buttons = [] rows.append(urwid.Text(u"Branch:")) for branch in change.project.branches: b = mywid.FixedRadioButton(self.branch_buttons, branch.name, state=(branch.name == change.branch)) rows.append(b) rows.append(urwid.Divider()) rows.append(urwid.Text(u"Commit message:")) rows.append(self.entry) rows.append(urwid.Divider()) rows.append(button_columns) pile = urwid.Pile(rows) fill = urwid.Filler(pile, valign='top') super(CherryPickDialog, self).__init__(urwid.LineBox(fill, 'Propose Change to Branch'))
def __init__(self, patchsets, old, new): button_widgets = [] ok_button = mywid.FixedButton('OK') cancel_button = mywid.FixedButton('Cancel') urwid.connect_signal(ok_button, 'click', lambda button: self._emit('ok')) urwid.connect_signal(cancel_button, 'click', lambda button: self._emit('cancel')) button_widgets.append(('pack', ok_button)) button_widgets.append(('pack', cancel_button)) button_columns = urwid.Columns(button_widgets, dividechars=2) left = [] right = [] left.append(urwid.Text('Old')) right.append(urwid.Text('New')) self.old_buttons = [] self.new_buttons = [] self.patchset_keys = {} oldb = mywid.FixedRadioButton(self.old_buttons, 'Base', state=(old == None)) left.append(oldb) right.append(urwid.Text('')) self.patchset_keys[oldb] = None for key, num in patchsets: oldb = mywid.FixedRadioButton(self.old_buttons, 'Patchset %d' % num, state=(old == key)) newb = mywid.FixedRadioButton(self.new_buttons, 'Patchset %d' % num, state=(new == key)) left.append(oldb) right.append(newb) self.patchset_keys[oldb] = key self.patchset_keys[newb] = key left = urwid.Pile(left) right = urwid.Pile(right) table = urwid.Columns([left, right]) rows = [] rows.append(table) rows.append(urwid.Divider()) rows.append(button_columns) pile = urwid.Pile(rows) fill = urwid.Filler(pile, valign='top') title = 'Patchsets' super(PatchsetDialog, self).__init__(urwid.LineBox(fill, title))