Transparent TextBrowser

Heads up! You've already completed this tutorial.

s05680089926 | 2021-02-12 12:01:34 UTC | #1

Hello everyone, I got a tricky question. I am pretty new to pyqt5. I build an object detection and everytime something gets detected i append a text to an textbrowser widget.

How I want that the last append appears with higher transparency than the apended text before. Any idea how to achieve that? Thanks in advance


martin | 2021-02-12 21:32:57 UTC | #2

When you say transparency, do you mean in a lighter colour, or is your text box actually transparent? Normally, the back of windows in Qt are filled in (although you can turn this off!)

If you're using QTextEdit you can use .setTextColor to set the color of the text, although for the effect you're after you'd have to reset the previous line back to the normal color too.

What I think I would do instead, is use a QListView (see model views https://www.pythonguis.com/tutorials/modelview-architecture/ ) and apply conditional formatting to the last element in the list. That way the appeance will be handled automatically.


s05680089926 | 2021-02-13 08:52:12 UTC | #3

I want to generate a fading out Effekt with the already appended text.


Over 10,000 developers have bought Create GUI Applications with Python & Qt!
Create GUI Applications with Python & Qt6
Take a look

Downloadable ebook (PDF, ePub) & Complete Source code

Also available from Leanpub and Amazon Paperback

[[ discount.discount_pc ]]% OFF for the next [[ discount.duration ]] [[discount.description ]] with the code [[ discount.coupon_code ]]

Purchasing Power Parity

Developers in [[ country ]] get [[ discount.discount_pc ]]% OFF on all books & courses with code [[ discount.coupon_code ]]
Well done, you've finished this tutorial! Mark As Complete
[[ user.completed.length ]] completed [[ user.streak+1 ]] day streak

Transparent TextBrowser was written by Martin Fitzpatrick .

Martin Fitzpatrick has been developing Python/Qt apps for 8 years. Building desktop applications to make data-analysis tools more user-friendly, Python was the obvious choice. Starting with Tk, later moving to wxWidgets and finally adopting PyQt.