[Urwid] fixed sized footer

Muhammad Ammar mammar at gmail.com
Wed Aug 11 12:03:25 EDT 2010


Hi All,

Following is a sample code, the problem is that when "txtstatus2msg" text
string is large the footer resize itself, how can i avoid footer resize.
i want to shift the text to next line without resizing the footer.

Anyone have any hint/idea?


import urwid
>
>
> palette = [('header', 'black', 'light gray'),
>            ('body', 'black', 'light blue'),
>            ('footer', 'black', 'light magenta')]
>
> txt_title = urwid.Text("My Application", 'center')
>
> txt_title = urwid.Pile([urwid.Divider(top=2),
>                         txt_title,
>                         urwid.Divider(top=1)])
>
> head = urwid.AttrMap(txt_title, 'header')
>
> txt_one = urwid.Text("one  ", 'center')
> txt_two = urwid.Text("two ", 'center')
> txt_close = urwid.Text("exit ", 'center')
>
> menuList = urwid.SimpleListWalker([
>                                        urwid.Divider(" "),
>                                        txt_one,
>                                        urwid.Divider(" "),
>                                        txt_two,
>                                        urwid.Divider(" "),
>                                        txt_close,
>                                        urwid.Divider(" "),
>                                       ])
>
> lb = urwid.ListBox(menuList)
>
> body = urwid.LineBox(lb)
> body = urwid.Padding(body, align='center', width=40)
> body = urwid.Filler(body, valign='middle', height=9)
> body = urwid.AttrMap(body, 'body')
>
> txt_status1       = urwid.Text("Status: ", 'left')
> txtstatus1msg     = urwid.Text("")
> txt_status2       = urwid.Text("Message: ")
> txtstatus2msg     = urwid.Text("")
>
> cols = urwid.Columns([('fixed', 10, txt_status1),
>                       ('fixed', 20, txtstatus1msg),
>                       ('fixed', 9, txt_status2),
>                                    txtstatus2msg], )
>
> status = urwid.Pile([urwid.Divider(top=1), cols, urwid.Divider(top=2)])
> status = urwid.Padding(status, 'center', 70)                   #can't
> change this, else controls will not be in center
>
> footer = urwid.AttrMap(status, 'footer')
>
> top = urwid.Frame(body, head, footer)
> top = urwid.AttrMap(top, 'bg')
>
> def OnKey(key):
>
>     if key == 'f6':
>
> txtstatus2msg.set_text("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
>
>     if key == 'f7':
>         txtstatus2msg.set_text("aaaaaaaaaaaaaaaaaaaaaaaaaaa")
>
> loop = urwid.MainLoop(top, palette, unhandled_input=OnKey)
> loop.run()
>

Regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.excess.org/pipermail/urwid/attachments/20100811/dcec7db9/attachment.htm 


More information about the Urwid mailing list