TomSchimansky / CustomTkinter

A modern and customizable python UI-library based on Tkinter
MIT License
11.33k stars 1.07k forks source link

add feature TextBox #2405

Closed mikdevind closed 4 months ago

mikdevind commented 4 months ago

please add jutify for textbox

Akascape commented 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

mikdevind commented 4 months ago

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')

Akascape commented 4 months ago

@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()
mikdevind commented 4 months ago

not work for centering text in CTkTextbox

mikdevind commented 4 months ago

Thanks you