Discussion:
[Urwid] Align buttons to the border of the screen
Oscar
2013-07-28 10:19:32 UTC
Permalink
Hi,

I'm new to urwid but alhough I'm following all examples and trying all
the widgets of the reference guide, I can't get two buttons aligned to
the border of the screen. With the following code I get both buttons
centered on the screen:

import urwid
palette = [ ('head','yellow','black'),
('reversed','standout',''),('hola','white','black'),('gg','black','dark
cyan')]

helpa=urwid.Button("help_A")
helpb=urwid.Button("help_B")

everything=urwid.GridFlow((helpa, helpb), 10, 3, 1, "center")
loop = urwid.MainLoop(urwid.Filler(everything),palette)
loop.run()

Current 0utput:


????????????????????????????????????????????????????????????????????????????????
?
?
?
?
?
?
?
?
?
?
?
?
? <help_A> <help_B>
?
?
?
?
?
?
?
?
?
|
|

????????????????????????????????????????????????????????????????????????????????

Output wanted:


????????????????????????????????????????????????????????????????????????????????
?
?
?
?
?
?
?
?
?
?
?
?
? <help_A>
<help_B> ?
?
?
?
?
?
?
?
?
|
|

????????????????????????????????????????????????????????????????????????????????

Thanks in advance!

--
Oscar
Oscar
2013-07-29 15:22:05 UTC
Permalink
Reading the docs I discovered that one of my problems can be solved
using a "Divider" widget between of the buttons.

Now only remains the other problem: How do I "pack" each button so
their width is not the maximum width available but the minimum width
needed to show them OK? I think that what I'm trying to do is convert
them from "box" widget to "fixed" widget but I cannot find a way to do
this in the docs.

Thanks!

--
Oscar
Post by Oscar
Hi,
I'm new to urwid but alhough I'm following all examples and trying all
the widgets of the reference guide, I can't get two buttons aligned to
the border of the screen. With the following code I get both buttons
import urwid
palette = [ ('head','yellow','black'),
('reversed','standout',''),('hola','white','black'),('gg','black','dark
cyan')]
helpa=urwid.Button("help_A")
helpb=urwid.Button("help_B")
everything=urwid.GridFlow((helpa, helpb), 10, 3, 1, "center")
loop = urwid.MainLoop(urwid.Filler(everything),palette)
loop.run()
????????????????????????????????????????????????????????
? ?
? ?
? ?
? ?
? ?
? ?
? <help_A> <help_B>> ?
? ?
? ?
? ?
? ?
????????????????????????????????????????????????????????
????????????????????????????????????????????????????????
? ?
? ?
? ?
? ?
? ?
? ?
? <help_A> <help_B>> ?
? ?
? ?
? ?
? ?
????????????????????????????????????????????????????????
Thanks in advance!
--
Oscar
_______________________________________________
Urwid mailing list
Urwid at lists.excess.org
http://lists.excess.org/mailman/listinfo/urwid
Ian Ward
2013-08-04 18:48:43 UTC
Permalink
Hello,

You can pack the widths of Text widgets with the Columns widget so
that they appear at the far right/left, but Buttons don't currently
support packing IIRC. Try using Columns with given widths for each
button and one column with a Divider in between that will expand to
fill the space.

Ian

Loading...