Python Forum
Transparent window background, but not text on it
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Transparent window background, but not text on it
#1
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.
Reply
#2
Show what you have tried.
Reply
#3
Take a look at pyqtside6
If you want a solution that does not require payment, even for commercial use, see wxpython
Reply
#4
(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()
Reply
#5
(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!
Reply
#6
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
Larz60+ write Jan-21-2024, 11:32 PM:
Removed added url
Reply
#7
(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!
Reply
#8
Did you try it?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Interaction between Matplotlib window, Python prompt and TKinter window NorbertMoussy 3 539 Mar-17-2024, 09:37 AM
Last Post: deanhystad
  [Tkinter] COMPLEX! Transparent Canvas Linux AceScottie 7 1,805 Jun-21-2023, 06:44 PM
Last Post: AceScottie
  [PyQt] Hover over highlighted text and open popup window DrakeSoft 2 1,535 Oct-29-2022, 04:30 PM
Last Post: DrakeSoft
  [Tkinter] Transparent Canvas finndude 8 10,118 Oct-02-2022, 01:48 PM
Last Post: joe_momma
  win32gui not transparent a color, just transparent all the wwindow DQT 0 1,101 Jul-29-2022, 01:40 PM
Last Post: DQT
  [Tkinter] Background inactivity timer when tkinter window is not active DBox 4 2,943 Apr-16-2022, 04:04 PM
Last Post: DBox
  [Tkinter] Not able to get image as background in a Toplevel window finndude 4 3,934 Jan-07-2022, 10:10 PM
Last Post: finndude
Photo Tkinter TEXT background image _ShevaKadu 5 7,806 Nov-02-2020, 10:34 AM
Last Post: joe_momma
  [Tkinter] How to show text in window? wxnerd 4 3,775 Jun-20-2020, 04:16 PM
Last Post: wxnerd
  Make Label Text background (default color) transparent using tkinter in python barry76 1 23,862 Nov-28-2019, 10:19 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020