[Python-mx] Ejemplo layout_listbox_example

Noe Nieto nnieto at noenieto.com
Thu Jul 28 01:08:28 EDT 2016


Hola, no se a que ejemplo te refieres, pero revisando el codigo ....

Con set_sort_func() le estas enseñando al listbox_2 cómo ordenar a sus
filas.

sort_func() toma tres parametros, pero en realidad solo esta usando los
primeros 2. Compara la propiedad/atributo data, que de seguro son cadenas.
Por eso el lower(). De la documentacion de GTK+3 en C [1]:

< 0 if *row1* should be before *row2* , 0 if they are equal and > 0
otherwise
En python 0 equivale a False, asi que tal vez la comparacion la resumen en
un simple " return x>y", pero no estroy seguro.


-- Noe


[1]
https://developer.gnome.org/gtk3/stable/GtkListBox.html#GtkListBoxSortFunc


2016-07-27 21:41 GMT-07:00 Javier Parada <jparada_a at hotmail.com>:

> Hola,
>
> Tratando de replicar (para aprender) el ejemplo
> de layout_listbox_example.py..., en buen español, que se indica con la
> función sort_func, es decir, qué se está comparando?, qué regresa?.
>
> > listbox_2 = Gtk.ListBox()
> > items = 'This is a sorted ListBox Fail'.split()
> >
> > for item in items:
> >     listbox_2.add(ListBoxRowWithData(item))
> >
> > def sort_func(row_1, row_2, data, notify_destroy):
> > return row_1.data.lower() > row_2.data.lower()
> >
> > listbox_2.set_sort_func(sort_func, None, False)
>
> Gracias.
>
> Saludos,
> Javier
> _______________________________________________
> Python-mx mailing list
> Python-mx at python.org
> https://mail.python.org/mailman/listinfo/python-mx
>



-- 
---
Noe Nieto
NNieto Consulting Services
M: nnieto at noenieto.com
W: http://noenieto.com
T:  @tzicatl <https://twitter.com/#%21/tzicatl>
Li: Perfil en LinkedIn <http://www.linkedin.com/profile/view?id=84300665>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-mx/attachments/20160727/430b0a1e/attachment.html>


More information about the Python-mx mailing list