-1

I want to make a python todo app with customtkinter. When i create a checkbox which has a longer text everytime something goes wrong and for something they just go away.

Here is my code so far:

from customtkinter import *
from tkinter import *
import random

root = CTk()
root.geometry('400x600')
root.title('Todo')
root.resizable(False, False)
set_appearance_mode('light')
set_default_color_theme('blue')


#Main label
main_label = CTkLabel(root, text='Your To Do list', font=CTkFont(size=30, weight='bold'))
main_label.place(x=20, y=20)

#Under label
under_label_choices_list = [
    'This will be your best day',
    'Be productive',
    'Willpower',
]
under_label_choices = StringVar()
under_label_choices.set(random.choice(under_label_choices_list))

under_label = CTkLabel(root, textvariable=under_label_choices, text_color='#6495ED', font=CTkFont(size=15, weight='bold'))
under_label.place(x=20, y=50)

#Scrollableframe
scrollableframe = CTkScrollableFrame(root, width=300, height=400)
scrollableframe.place(x=40, y= 100)

#Add button
**def make_checkbox(event):
    global todo_entry
    checkbox = CTkCheckBox(scrollableframe, text=todo_entry.get(), font=CTkFont(size=15))
    todo_entry.destroy()
    checkbox.grid(padx=5, pady=5)


def add():
    global todo_entry
    todo_entry = CTkEntry(scrollableframe)
    todo_entry.bind('<Return>', make_checkbox)
    todo_entry.grid(padx=5, pady=5)
    todo_entry.focus()**


add_button = CTkButton(root, text='Add', command=add)
add_button.place(x=20, y=540)



root.mainloop()

I think the problem is in the bold part

Here is a picture too how it's looks like

Adriaan
  • 17,741
  • 7
  • 42
  • 75
Illes
  • 3
  • 2
  • Welcome to Stack Overflow! Please don't add "solved" to your question title or body. [Answering your own question is allowed and even encouraged](https://stackoverflow.com/help/self-answer). – Adriaan Mar 16 '23 at 15:40

2 Answers2

0

Try adding a width to the check box

def make_checkbox(event):
    global todo_entry
    checkbox = CTkCheckBox(scrollableframe, text=todo_entry.get(), font=CTkFont(size=15), width=200)
    todo_entry.destroy()
    checkbox.grid(padx=5, pady=5)

Now it should be fine.

-1

Try adding sticky='w' to the checkbox.grid() call, to make it align to the left side of the container.

Ben the Coder
  • 539
  • 2
  • 5
  • 21