Home > OS >  how to change a window border color in tkinter
how to change a window border color in tkinter

Time:09-22

I'm having a problem with changing the background of this part of the window:

enter image description here

How do I change it?

CodePudding user response:

#import tkinter
from tkinter import *
#Create Tk object
window = Tk()
# Set the window title
window.title('GFG')
# Entry Widget
# highlightthickness for thickness of the border
entry = Entry(highlightthickness=2)
# highlightbackground and highlightcolor for the border color
entry.config(highlightbackground = "red", highlightcolor= "red")
# Place the widgets in window
entry.pack(padx=20, pady=20)
window.mainloop()

CodePudding user response:

As I see you are using windows.

This color is set by the theme you are currently using. It is the same for every window.

So I cross out the possibility of only using the Tkinter module for this.

Tkinter is responsible for what is in the window but the window manager decides about the border. For example in Ubuntu the window would look totally different.

I guess, you would need some windows specific calls for that.

You can remove the border with root.overrideredirect(1) if I remember correctly.

  • Related