Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

customtkinter - How to edit CTkEntry border?

So I'm using the customtkinter to create an interface. I have an entry and I want it to have a background, but I cant't do it. In the documentation, there isn't an argument for the border. Specifically, I want to change the width and the color. Does anyone know how I can do it?

from tkinter import mainloop
import customtkinter as ctk

root = ctk.CTk()
root.geometry("200x200")

e = ctk.CTkEntry(master=root,
  text_color="green",
  font=("tahoma", 20),
  # borderwidth=5,
  # bd=5,
)
e.insert(0, "text goes here...")
e.pack()

mainloop()

Here bd throws an error. borderwidth works but not as expected. Maybe you can't just edit the border in the CTkEntry widget. But I don't know.

like image 970
leech Avatar asked May 23 '26 11:05

leech


1 Answers

The CTkEntry widget now has a border as of version 3.0. You can upgrade customtkinter like this:

pip3 install customtkinter --upgrade

To edit the border you can pass the border_width option and border_color option:

import tkinter
import customtkinter

root_tk = customtkinter.CTk()
root_tk.geometry("400x340")

entry = customtkinter.CTkEntry(root_tk, border_width=2, border_color="gray50")
entry.pack(pady=y_padding, padx=10, pady=20)

root_tk.mainloop()

Documentation: https://customtkinter.tomschimansky.com/documentation/

like image 156
Tom Avatar answered May 26 '26 00:05

Tom