I am a newcomer to using the Urwid library (built in Python) and I am trying to understand some existing urwid examples at urwid examples. One of them being this code :
import urwid
palette = [
('banner', 'black', 'light gray', 'standout,underline'),
('streak', 'black', 'dark red', 'standout'),
('bg', 'black', 'dark blue'),]
txt = urwid.Text(('banner', u" Hello World "), align='center')
map1 = urwid.AttrMap(txt, 'streak')
fill = urwid.Filler(map1)
map2 = urwid.AttrMap(fill, 'bg')
def exit_on_q(input):
if input in ('q', 'Q'):
raise urwid.ExitMainLoop()
loop = urwid.MainLoop(map2, palette, unhandled_input=exit_on_q)
loop.run()
- How do the attributes work in this example ?
- What does it mean by foreground and background?
- What does it mean by map1 "wraps" txt ? Does it mean you create a widget named map1 and place the widget over the screen position at which txt is placed ? Does the phrase "wrapping a widget A with another widget B" mean the same as when we say "map widget A onto widget B" ?
- Is map1 the original_widget for the Filler decoration widget ?
- What code part match the vertical height of streak match exactly with vertical height of txt ? Why didn't the vertical height of streak become bigger or smaller than vertical height of txt ? If there would be no map2 then would it mean that the rest of the screen apart from txt1 would be red or just black ?