Reputation: 378
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.
Upvotes: 3
Views: 5934
Reputation: 753
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/
Upvotes: 4
Reputation: 1
CUSTOMTKINTER For border there isn't a syntax but you can make a border using border_width="" and for coloring your border you can use border_color=""
to add background color for you entry use bg_color="" FOR SOME USERS u may find your corner radius is showing like it's corner is having a leftover of a square like it's corners are being build out of normal tkinter entry(usually found when you have a background image) for that use bg_color and fg_color inside the entry to blend it
in your code you don't have to type insert externally for temporary text, in customtkinter you can use placeholder_text="" INSIDE ENTRY, it will automatically delete that text when clicked and pops back when focus is out, to change color of that text use placeholder_text_color=""
Upvotes: 0