summaryrefslogtreecommitdiff
path: root/configs/apps/gladevcp/colored-label/README
blob: c51bc8b7d7bb7d0433552806f4c3bfe816a211de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
How to colorize a HAL_Label widget depending on the pin value
-------------------------------------------------------------

Setting the background color of a GtkLabel widget (and HAL_Label is
derived from GtkLabel) is a bit tricky. The GtkLabel widget has no
window object of its own for performance reasons, and only window
objects can have a background color. The solution is to enclose the
Labl in an EventBox container, which has a window but is otherwise
invisible - see the coloredlabel.ui file.

To help with this, the colorize() method tries to detect this
situation and give a warning if the widget is a GtkLabel and the
parent widget is not an GtkEventBox. It can be used to set the colors
of arbitray widgets, not just GtkLabel.

Also, this example shows how to set a custon text and color label
depending on the HAL pin's value.

------------------------------------------
To run independently:

$ gladevcp -u coloredlabel.py -H coloredlabel.hal coloredlabel.ui