Listbox fill=BOTH expand=YES (Tkinter)

H

Harlin Seritt

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
 
M

Martin Franklin

Harlin said:
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

Harlin,

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

Martin
 
R

Raseliarison nirinA

Martin Franklin said:
Harlin,

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

Martin

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

Raseliarison nirinA

Christos TZOTZIOY Georgiou said:
I hope you also know that

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

is also True...

yeah, known but forgotten.

hmmm .......
let's try :
False

so True

i'll recite 42 times truth tables before going to bed.
however i didn't expect the following:
True

hmmm...
True

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

i expected this to be true, but it's not:
>>> set(['TRUE','YES']) in set(dir(Tkconstants))
False

originaly, i'm thinking to short-cut the following,
>>> reduce(lambda t,f: t and f, [i in dir(Tkconstants) for i in
'YES','inexistent keyword'])
False
>>> reduce(lambda t,f: t and f, [i in dir(Tkconstants) for i in
'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!
 
C

Christos TZOTZIOY Georgiou

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

i expected this to be true, but it's not:
set(['TRUE','YES']) in set(dir(Tkconstants))
False

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(Tkconstants))
True
 
R

Raseliarison nirinA

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

ah! yes. that's clear now. thanks!
after all:
print element,

why did i think that 'in' was another different operator?
the test should be then:
True

and then:
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:
"Returns True if pred(x) is True for every element in the
iterable"
for elem in ifilterfalse(pred, seq):
return False
return True
all(i in dir(Tkconstants) for i in ['TRUE', 'YES']) True
all(i in dir(Tkconstants) for i in ['TRUE', 'YES', 'inexistent
key'])
False

lovely...
i do not regret the fate of reduce et al.
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(Tkconstants))
True

i noted! thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,222
Messages
2,571,142
Members
47,757
Latest member
PDIJaclyn

Latest Threads

Top