I have a program that I want to remove the title bar of the window and add rounded corner.
My current approach is:
Then use a
.css file to add rounded corners
This method works to add the rounded corner but a black background appears behind the window as shown below.
Any ways to fix this issue or work around to add rounded borders.
Which version of GTK are you using?
Which platform and windowing system are you using?
I am using Gtk version 3.0 with xfce as the desktop environment
You will need an X11 compositor running, and you will need to set the RGBA visual on your top level window:
I tried the following example and it worked fine with gnome. But I didn’t worked successfully with xfce.
What should I check to make sure it would work in xfce.
Like X11, or xfwm version?
from gi.repository import Gtk, Gdk
supports_alpha = False
def screen_changed(widget, old_screen, userdata=None):
screen = widget.get_screen()
visual = screen.get_rgba_visual()
if visual is None:
print("Your screen does not support alpha channels!")
visual = screen.get_system_visual()
supports_alpha = False
print("Your screen supports alpha channels!")
supports_alpha = True
def expose_draw(widget, event, userdata=None):
cr = Gdk.cairo_create(widget.get_window())
print("setting transparent window")
cr.set_source_rgba(1.0, 1.0, 1.0, 0.0)
print("setting opaque window")
cr.set_source_rgb(1.0, 1.0, 1.0)
def clicked(window, event, userdata=None):
# toggle window manager frames
if __name__ == "__main__":
window = Gtk.Window()
fixed_container = Gtk.Fixed()
button = Gtk.Button.new_with_label("button1")
screen_changed(window, None, None)
Did you enable compositing on xfwm? You must use a compositor to have rounded corners.
Yep, it worked enabling the compositor did the trick.
I Enabled the compositor using
Window Manager Tweaks.
I am facing a new issue when adding the previous code. It removes the images background and make the buttons acts weird. as shown in the image.
So now I have rounded corners but I have missed up widgets
Nevermind, the code that I paste post#6 removed the widgets transparent.
The solution is only to use @ebassi and @Hamza_Algohary solutions and it will solve the rounded corner problem. solution
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.