[PyKDE] QLCDNumber color/style

Larry Wright larry.tami at gte.net
Thu Sep 18 21:57:00 BST 2003


> Tony Cappellini wrote:
>> Would someone point me to an example on how to change the look of a
>> QLCDNumber widget ?  I would like to change the color, and perhaps
>> make it bold, or just easier to read.  The grey is hard to see at a
>> distance.
>>
>> Is it even possible to change the colors on this widget ?
>
> To make it more readable, try either
>
>     QLCDNumber.setSegmentStyle(QLCDNumber.Filled) or
>     QLCDNumber.setSegmentStyle(QLCDNumber.Flat)
>
> The filled option has a nice highlight, but still looks grey at small
> sizes.  Flat has no highlight, so it is dark at any size.
>
> For an example, see <http://bellz.org/rpcalc/>.
>
> I've never tried chnaging the color, but I assume you could call
> QWidget.setPalette(...) like any other widget.
>
> Doug.

You're correct, here's some code I wrote some time ago:

        black = QColor("black")

        green = QColor("green")

        red = QColor("red")

        self.safeColor = QPalette()

        self.safeColor.setColor(QColorGroup.Background,black)

        self.safeColor.setColor(QColorGroup.Foreground,green)



        self.warnColor = QPalette()

        self.warnColor.setColor(QColorGroup.Background,black)

        self.warnColor.setColor(QColorGroup.Foreground,red)



        self.display.setPalette(self.safeColor)

        self.display.setSegmentStyle(QLCDNumber.Flat)

For this app, I am keeping track of the number of users connected to my
jabber server, and I want the color to change on the LCD when the number
goes over a certain threshold. The above code snippet just sets up two
palettes, and I can switch between them like this:
         if (count < 1000):

            self.display.setPalette(self.safeColor)

          else:

            self.display.setPalette(self.warnColor)

HTH,
Larry

> _______________________________________________
> PyKDE mailing list    PyKDE at mats.imk.fraunhofer.de
> http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
>
>
>




More information about the PyQt mailing list