pls explain this flags use

Ian Kelly ian.g.kelly at gmail.com
Wed Dec 28 12:56:58 EST 2011


On Wed, Dec 28, 2011 at 10:16 AM, Tracubik <affdfsdfdsfsd at b.com> wrote:
> Hi all,
> i've found here (http://python-gtk-3-tutorial.readthedocs.org/en/latest/
> layout.html#table) this code:
>
> [quote]
> If omitted, xoptions and yoptions defaults to
> Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL.
> [end quote]
>
> xoptions have 3 flags: EXPAND, FILL, SHRINK
>
> so, how it is supposed to work?
> it means that by default xoptions is set to EXPAND true, FILL true,
> SHRINK false?

Yes.

> how it work? "|" is used with bits afaik, so i suppouse the xoptions is 3
> bits?

Yes.

> and the default is
> EXPAND FILL SHRINK
>  1      1     0
>
> (or something similar)
>
> so i have
>
> AttachOptions.EXPAND = 100
> AttachOptions.FILL   = 010
>
> EXPAND|FILL = 100|010 = 110
>
> is that right?
> so if i want EXPAND *and* FILL i have to make EXPAND *binary or* FILL?

Yes.  Binary or is used to set flags, binary and is used to test
whether specific flags are set, e.g.:

if options & AttachOptions.EXPAND:
    # do something expandy
else:
    # do something not expandy



More information about the Python-list mailing list