How can i change color in tree views?

In tryton, can i change color of tree/form views? and if answer is yes, how can i do?

It depends what you mean by “Can I change color of tree/form views”.

There are some customization through GTK theme.

But if you want some rows to be of a different color according to the value of a field, then you’ll have to use an icon instead of the color (this has been done for accessibility reasons).

1 Like

how can i use icon? because that is i want to do

You have to put an affix (usually a prefix) with the attribute icon: Views — trytond 5.3 documentation

(Or a shortcut is to use the icon attribute on the field)

2 Likes

but those icon can be personalized or i must use the default icon of tryton?

You can define your own icons. Here’s how it’s done in the account module:

http://hg.tryton.org/modules/account/file/tip/account.xml#l30

2 Likes

We should write a topic about icon in the documentation.

1 Like

Por ejemplo, en un treeview es necesario una columa estado en cada linea, y el color de la linea debe ser distinto para cada estado. Es posible hacerlo?

As Nicolas said, you have to use an icon instead of a color for the whole row. But of course, this icons can be of any color you want.

Gracias x responder, pero veo que en la referencia de Nico es para poner iconos a los menĂşs y en la que da cedric te pone el icono al campo/columna entera en todas las filas/lĂ­neas. Lo que busco es diferentes colores o iconos basados en el valor de cada fila/lĂ­nea, especĂ­ficamente es un campo/columna de estado que quiero diferenciar. No veo donde pongo la condiciĂłn para que cambie en cada estado o valor del campo /columna

The icon attribute must contain the name of the field that contains the name of the icon to display. So you will have a different icon per row depending of the value of the field (usually Function field).

Tienes que definir un campo que puede ser funciĂłn, y con ese recuperar el Ă­cono a mostrar.

Ya lo conseguí, tuve que crear 4 campos funcionales, 1 donde en el get_xxxx dependiendo del estado de la fila, retorna el nombre de otros 3 campos funcionales que contiene el nombre del icono a mostrar (previamente registrado con su ir.ui.icon) . En el xml de vista del treeview dentro del “field” uso el atributo icon=“nombre del campo 1”. .

2 Likes