Listbox fill=BOTH expand=YES (Tkinter)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Harlin Seritt

    #1

    Listbox fill=BOTH expand=YES (Tkinter)

    I am trying the following:

    Listbox(parent) .pack(fill=BOTH , expand=YES)

    I notice that the listbox will fill on the X axis but will not on the Y
    axis unlike other widgets. Is there any way to force this?

    thanks,

    Harlin

  • Martin Franklin

    #2
    Re: Listbox fill=BOTH expand=YES (Tkinter)

    Harlin Seritt wrote:[color=blue]
    > I am trying the following:
    >
    > Listbox(parent) .pack(fill=BOTH , expand=YES)
    >
    > I notice that the listbox will fill on the X axis but will not on the Y
    > axis unlike other widgets. Is there any way to force this?
    >
    > thanks,
    >
    > Harlin
    >[/color]

    Harlin,

    It should expand (and fill ) in both directions have you checked it's
    parents packing options?

    Martin



    Comment

    • Harlin Seritt

      #3
      Re: Listbox fill=BOTH expand=YES (Tkinter)

      That was it Martin. I forgot to expand the parent.

      Thanks!

      Comment

      • Raseliarison nirinA

        #4
        Re: Listbox fill=BOTH expand=YES (Tkinter)

        "Martin Franklin" wrote:
        [color=blue]
        > Harlin Seritt wrote:[color=green]
        > > I am trying the following:
        > >
        > > Listbox(parent) .pack(fill=BOTH , expand=YES)
        > >
        > > I notice that the listbox will fill on the X axis but will not on
        > > the Y axis unlike other widgets.
        > > Is there any way to force this?
        > >
        > > thanks,
        > >
        > > Harlin
        > >[/color]
        >
        > Harlin,
        >
        > It should expand (and fill ) in both directions have you checked
        > it's parents packing options?
        >
        > Martin
        >[/color]

        is YES a valid flag for expand?
        maybe expand=1

        --
        nirinA


        Comment

        • Harlin Seritt

          #5
          Re: Listbox fill=BOTH expand=YES (Tkinter)

          either YES, True, or 1 should work.

          Comment

          • Raseliarison nirinA

            #6
            Re: Listbox fill=BOTH expand=YES (Tkinter)

            "Harlin Seritt" wrote:[color=blue]
            > either YES, True, or 1 should work.
            >[/color]

            yes, indeed.[color=blue][color=green][color=darkred]
            >>> import Tkconstants
            >>> 'True' and 'YES' in dir(Tkconstants )[/color][/color][/color]
            True

            thanks Harlin,

            --
            nirinA


            Comment

            • Christos TZOTZIOY Georgiou

              #7
              Re: Listbox fill=BOTH expand=YES (Tkinter)

              On Tue, 15 Mar 2005 16:48:17 +0300, rumours say that "Raseliaris on nirinA"
              <nirina@mail.bl ueline.mg> might have written:
              [color=blue]
              >yes, indeed.[color=green][color=darkred]
              >>>> import Tkconstants
              >>>> 'True' and 'YES' in dir(Tkconstants )[/color][/color]
              >True
              >
              >thanks Harlin,[/color]

              I hope you also know that

              ..>> 'inexistent keyword' and 'YES' in dir(Tkconstants )

              is also True...
              --
              TZOTZIOY, I speak England very best.
              "Be strict when sending and tolerant when receiving." (from RFC1958)
              I really should keep that in mind when talking with people, actually...

              Comment

              • Raseliarison nirinA

                #8
                Re: Listbox fill=BOTH expand=YES (Tkinter)

                "Christos TZOTZIOY Georgiou" wrote:[color=blue]
                > On Tue, 15 Mar 2005 16:48:17 +0300,
                > rumours say that [i] might have written:
                >[color=green]
                > >yes, indeed.[color=darkred]
                > >>>> import Tkconstants
                > >>>> 'True' and 'YES' in dir(Tkconstants )[/color]
                > >True
                > >
                > >thanks Harlin,[/color]
                >
                > I hope you also know that
                >
                > .>> 'inexistent keyword' and 'YES' in dir(Tkconstants )
                >
                > is also True...[/color]

                yeah, known but forgotten.

                hmmm .......
                let's try :
                [color=blue][color=green][color=darkred]
                >>> import Tkconstants
                >>> 'YES' in dir(Tkconstants )[/color][/color][/color]
                True[color=blue][color=green][color=darkred]
                >>> 'True' in dir(Tkconstants )[/color][/color][/color]
                False[color=blue][color=green][color=darkred]
                >>> 'TRUE' in dir(Tkconstants )[/color][/color][/color]
                True[color=blue][color=green][color=darkred]
                >>> ('inexistent keyword') in dir(Tkconstants )[/color][/color][/color]
                False

                so[color=blue][color=green][color=darkred]
                >>> 'TRUE' and 'YES' in dir(Tkconstants )[/color][/color][/color]
                True[color=blue][color=green][color=darkred]
                >>> 'inexistent keyword' and 'YES' in dir(Tkconstants )[/color][/color][/color]
                True

                i'll recite 42 times truth tables before going to bed.
                however i didn't expect the following:
                [color=blue][color=green][color=darkred]
                >>> 'inexistent keyword' or 'YES' in dir(Tkconstants )[/color][/color][/color]
                'inexistent keyword'[color=blue][color=green][color=darkred]
                >>> False or 'YES' in dir(Tkconstants )[/color][/color][/color]
                True

                hmmm...
                [color=blue][color=green][color=darkred]
                >>> ('inexistent keyword' or 'YES') in dir(Tkconstants )[/color][/color][/color]
                False[color=blue][color=green][color=darkred]
                >>> (False or 'YES') in dir(Tkconstants )[/color][/color][/color]
                True

                i'll recite 42 times precedence rules before going to bed.
                but now i'm a bit confused by the -in- operator. as:
                [color=blue][color=green][color=darkred]
                >>> set(['TRUE','YES']).issubset(set( dir(Tkconstants )))[/color][/color][/color]
                True

                i expected this to be true, but it's not:
                [color=blue][color=green][color=darkred]
                >>> set(['TRUE','YES']) in set(dir(Tkconst ants))[/color][/color][/color]
                False

                originaly, i'm thinking to short-cut the following,[color=blue][color=green][color=darkred]
                >>> reduce(lambda t,f: t and f, [i in dir(Tkconstants ) for i in[/color][/color][/color]
                'YES','inexiste nt keyword'])
                False[color=blue][color=green][color=darkred]
                >>> reduce(lambda t,f: t and f, [i in dir(Tkconstants ) for i in[/color][/color][/color]
                'TRUE','YES'])
                True

                but that was too short and i miss something!
                i do reset my brain somewhere between cell234 and cell241
                thanks for reading!

                --
                nirinA
                --


                Comment

                • Christos TZOTZIOY Georgiou

                  #9
                  Re: Listbox fill=BOTH expand=YES (Tkinter)

                  On Thu, 17 Mar 2005 00:54:46 +0300, rumours say that "Raseliaris on nirinA"
                  <nirina@mail.bl ueline.mg> might have written:
                  [color=blue]
                  >i'll recite 42 times precedence rules before going to bed.
                  >but now i'm a bit confused by the -in- operator. as:
                  >[color=green][color=darkred]
                  > >>> set(['TRUE','YES']).issubset(set( dir(Tkconstants )))[/color][/color]
                  > True[/color]
                  [color=blue]
                  >i expected this to be true, but it's not:
                  >[color=green][color=darkred]
                  > >>> set(['TRUE','YES']) in set(dir(Tkconst ants))[/color][/color]
                  > False[/color]

                  the 'in' operator searches for existance of *elements* in a set, not of
                  *subsets*. BTW, only a frozenset can be included in a set.

                  To check for subsets, either use the issubset function, or the '<' operator (I
                  believe they both call the same code):

                  ..>> set(['TRUE','YES']).issubset(set( dir(Tkconstants )))
                  True

                  can be expressed as

                  ..>> set(['TRUE','YES']) < set(dir(Tkconst ants))
                  True
                  --
                  TZOTZIOY, I speak England very best.
                  "Be strict when sending and tolerant when receiving." (from RFC1958)
                  I really should keep that in mind when talking with people, actually...

                  Comment

                  • Raseliarison nirinA

                    #10
                    Re: Listbox fill=BOTH expand=YES (Tkinter)

                    "Christos TZOTZIOY Georgiou" wrote:[color=blue]
                    >
                    > the 'in' operator searches for existance of *elements* in a set, not
                    > of *subsets*. BTW, only a frozenset can be included in a set.[/color]

                    ah! yes. that's clear now. thanks!
                    after all:
                    [color=blue][color=green][color=darkred]
                    >>> for element in aset:[/color][/color][/color]
                    print element,

                    why did i think that 'in' was another different operator?
                    the test should be then:
                    [color=blue][color=green][color=darkred]
                    >>> 'TRUE' in dir(Tkconstants ) and 'YES' in dir(Tkconstants )[/color][/color][/color]
                    True

                    and then:
                    [color=blue][color=green][color=darkred]
                    >>> 'inexistent keyword' in dir(Tkconstants ) and 'YES' in[/color][/color][/color]
                    dir(Tkconstants )
                    False

                    a bit cumbersome if there is a lot of keys to test.
                    i also found in the itertools-recipes the way to avoid
                    the reduce-lambda construction i had previously in head:
                    [color=blue][color=green][color=darkred]
                    >>> from itertools import *
                    >>> def all(seq, pred=bool):[/color][/color][/color]
                    "Returns True if pred(x) is True for every element in the
                    iterable"
                    for elem in ifilterfalse(pr ed, seq):
                    return False
                    return True
                    [color=blue][color=green][color=darkred]
                    >>> all(i in dir(Tkconstants ) for i in ['TRUE', 'YES'])[/color][/color][/color]
                    True[color=blue][color=green][color=darkred]
                    >>> all(i in dir(Tkconstants ) for i in ['TRUE', 'YES', 'inexistent[/color][/color][/color]
                    key'])
                    False

                    lovely...
                    i do not regret the fate of reduce et al.
                    [color=blue]
                    >
                    > To check for subsets, either use the issubset function, or the '<'[/color]
                    operator (I[color=blue]
                    > believe they both call the same code):
                    >
                    > .>> set(['TRUE','YES']).issubset(set( dir(Tkconstants )))
                    > True
                    >
                    > can be expressed as
                    >
                    > .>> set(['TRUE','YES']) < set(dir(Tkconst ants))
                    > True[/color]

                    i noted! thanks again.

                    --
                    nirinA
                    --



                    Comment

                    Working...