Closed mikdevind closed 4 months ago
@mikdevind The textbox widget is similar to the text widget of tkinter and both don't have the justify option directly, you have to use tag method like mentioned here:
https://www.tutorialspoint.com/how-to-set-justification-on-tkinter-text-box
inputanSearch.tag_configure("center", justify='center') AttributeError: 'CTkTextbox' object has no attribute 'tag_configure'
program is inputanSearch = tk.CTkTextbox(FrameHome, wrap="none",font=("Times", 20), height=45, width=890) inputanSearch.grid(row=0, column=0, padx=3, pady=5) inputanSearch.tag_configure("center", justify='center')
@mikdevind Try this:
import customtkinter
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
self.grid_rowconfigure(0, weight=1) # configure grid system
self.grid_columnconfigure(0, weight=1)
self.textbox = customtkinter.CTkTextbox(master=self, width=400, corner_radius=0)
self.textbox.grid(row=0, column=0, sticky="nsew")
self.textbox._textbox.tag_configure("text", justify='center') # first, justify text position using tag_configure
self.textbox.insert("0.0", "Some example text!\n" * 20) # insert all the text
self.textbox._textbox.tag_add("text", "0.0", "end") # add this line in the end
app = App()
app.mainloop()
not work for centering text in CTkTextbox
Thanks you
please add jutify for textbox