Python Forum

Full Version: Transparent window background, but not text on it
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
Show what you have tried.
Take a look at pyqtside6
If you want a solution that does not require payment, even for commercial use, see wxpython
(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()
(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!
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
(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!
Did you try it?
(Feb-02-2024, 01:28 AM)Joically Wrote: [ -> ]Did you try it?

Of course. Promising results.