#🔒 Setting transparent window on Linux

26 messages · Page 1 of 1 (latest)

hollow willow
#

Hi, I got a python script with tkinter, where app.attributes('-transparentcolor', app['bg']) is used to remove the window background. The content is fully visible. But this seems to work only on window, but on my linux client it returns an error:
"Bad attribute -transparentcolor"

I've tried some variants from google search with "-alpha" or with app.configure(bg='') but nothing is working. Maybe one of you have any idea ?

elfin pulsarBOT
#

@hollow willow

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

dusky coyote
#

From what I saw online, you need app.wm_attributes('-alpha', 0.0)

#

@hollow willow

cinder ore
hollow willow
#

@dusky coyote but then is everything completely transparent. Nothing visible. The Window just contains some Buttons, they will disappear also with -alpha 0.0

#

@cinder ore do you mean in combination with -transparentcolor ?

dusky coyote
#

apparently you also need app.wait_visibility(app)

cinder ore
#

No, you don't need that.

#
import tkinter as tk

root = tk.Tk()
root.title("Transparent Window")
root.attributes('-type', 'normal')
root.attributes('-alpha', 0.6)

root.mainloop()
#

That works on my system.

hollow willow
#

let me try

cinder ore
#

I'm using xfwm4

#

You need a compositing window manager for this to work.

#

If you want the individual widgets to be transparent you may have to set the transparency attribute individually. I don't know.

hollow willow
#
app = tk.Tk()
app.title("URL Opener")
app.attributes('-topmost', True)  # Ensure the window stays on top
app.wm_overrideredirect(True)  # Remove window decorations
app.attributes('-type', 'normal');
#app.attributes('-transparentcolor', app['bg'])
#app.wait_visibility(app)
app.wm_attributes("-alpha", 0.5)
cinder ore
#

No, you don't seem to need that.

#

I made a button and didn't set any attributes with it and it seems to inherit the alpha from the root window.

hollow willow
#

@dusky coyote as you see in my snippet I tried that also

#

@cinder ore yes, but I don't want my buttons to inherit the alpha

cinder ore
#

You might have to set the alpha individually then - perhaps there's an attribute you can set so they don't inherit it.

hollow willow
#

ok, I will try that, good Idea, thank you.

cinder ore
#

You're welcome.

hollow willow
#

Ok, I give up. I think there is no way to achieve what I want with linux

elfin pulsarBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.