Python Forum
Transparent window background, but not text on it - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: Transparent window background, but not text on it (/thread-40261.html)



Transparent window background, but not text on it - muzicman0 - Jul-01-2023

I'm fairly new (or at least inexperienced) with Python, and this is the first project where I am trying to make a GUI.

What I am trying to accomplish is a window with no title bar that is semi transparent, say like 30% transparent. I have accomplished this with no issue, using both pysimplegui and tkinter. The problem that I am running into is that anything else (such as text) that I add to the window is also transparent. I don't want that. JUST a transparent background. Is this possible?

Any help would be much appreciated.


RE: Transparent window background, but not text on it - deanhystad - Jul-01-2023

Show what you have tried.


RE: Transparent window background, but not text on it - Larz60+ - Jul-01-2023

Take a look at pyqtside6
If you want a solution that does not require payment, even for commercial use, see wxpython


RE: Transparent window background, but not text on it - muzicman0 - Jul-01-2023

(Jul-01-2023, 11:58 AM)deanhystad Wrote: Show what you have tried.

This is just a quick test that I have been using, but here is code that creates a window that is semi transparent, and the text is also semi transparent.

# Import module
from tkinter import *
 
# Create object
root = Tk()
 
# Adjust size
root.geometry("1000x400")

# Create transparent window
root.attributes('-alpha', .8)
root.configure(bg= '#000001')

# Create label
l = Label(root, fg= 'white', bg= '#000001', text = "----SEMI TRANSPARENT TEXT-SHOULD BE 100% OPAQUE----")
l.config(font =("Courier", 24, 'bold'))

l.pack()

# Execute tkinter
root.mainloop()



RE: Transparent window background, but not text on it - muzicman0 - Jul-01-2023

(Jul-01-2023, 11:58 AM)Larz60+ Wrote: Take a look at pyqtside6
If you want a solution that does not require payment, even for commercial use, see wxpython

I will, thanks!


RE: Transparent window background, but not text on it - miranda23 - Jan-20-2024

Quote:Take a look at pyqtside6
If you want a solution that does not require payment, even for commercial use, see wxpython
A very good idea, I will try it


RE: Transparent window background, but not text on it - EdwardMatthew - Jan-23-2024

(Jul-01-2023, 03:53 AM)muzicman0 Wrote: I'm fairly new (or at least inexperienced) with Python, and this is the first project where I am trying to make a GUI.

What I am trying to accomplish is a window with no title bar that is semi transparent, say like 30% transparent. I have accomplished this with no issue, using both pysimplegui and tkinter. The problem that I am running into is that anything else (such as text) that I add to the window is also transparent. I don't want that. JUST a transparent background. Is this possible?

Any help would be much appreciated.

a short overview of Tkinter and PySimpleGUI from my side:
Tkinter creates a Tkinter window, sets transparency using attributes('-alpha', 0.7), and adds a frame with a non-transparent text label.
If we talk about the PySimpleGUI Set PySimpleGUI theme, Create a layout with a text element, and Create a window with transparent_color and alpha_channel, If you need more specific details or code, feel free to ask!


RE: Transparent window background, but not text on it - Joically - Feb-02-2024

Did you try it?