[wxpython-users] why doesn't fontlist sort work ?

Mike Driscoll mdriscoll at co.marshall.ia.us
Fri May 2 08:00:13 PDT 2008


Stef,
> <div class="moz-text-flowed" style="font-family: -moz-fixed">hello,
> I want to see all available fonts,
> so I used the following:
>
>  fonts = wx.FontEnumerator ()
>  fonts.EnumerateFacenames ()
>  fontList = fonts.GetFacenames ()#.sort()
>  print fontList
>
> now if I want to see the list ordered,
> I would expect to add the sort() method
> (I've verified that the type of fontList equals list),
> but I get None ?
>
> thanks,
> Stef
>
>
> </div>
This is a sneaky Python thing. Sorting is done "in place", so if you try 
to assign that, it return none. Instead, change you sort line to:

fontList = fonts.GetFacenames ()
fontList.sort()

See also: http://wiki.python.org/moin/HowTo/Sorting

Mike


More information about the wxpython-users mailing list