how to pass the value from checkboxes from one screen to next screen in Urwid?

57 Views Asked by At

hi everyone i am new with the urwid. i want to send the values of checkboxes which are selected from checkbox list it will send the next page i want to use these value in my next function how can archive this.below is my code

from urwid import (CheckBox, SimpleListWalker, ListBox, Text, Frame,
                   MainLoop, ExitMainLoop, connect_signal)

words = ["obelus", "bumfuzzle", "rubaboo", "ballyhoo", "everywhen",
         "octothorpe", "meldrop", "sozzled", "pizazz", "pronk"]
palette = [
        ('reverse','light gray','black'),
        ('important','dark blue','light gray',('standout','underline')),
        ('buttn','white','default'),
        ('buttnf','white','dark blue','bold'),
        ('h2', 'white,underline,bold', 'dark red'),
        ('header','white','dark red', 'bold'),
        ('body', 'default', 'default'),]

def update_footer(widget, state):

  footer.set_text(", ".join([checkbox.label
                            for checkbox in checkboxes
                            if checkbox.state is True]))

checkboxes = []

for word in words:
  checkbox = CheckBox(label=word)
  connect_signal(checkbox, "postchange", update_footer)
  checkboxes.append(checkbox)

list_walker = SimpleListWalker(contents=checkboxes)

listbox = ListBox(list_walker)

footer = Text(markup="")


print(listbox)
frame = Frame(header=header , body=listbox)

MainLoop(widget=frame).run()
0

There are 0 best solutions below