#๐Ÿ”’ Problem using customTkinter

20 messages ยท Page 1 of 1 (latest)

sour dirge
#

Hi, I use Ctk to create a window saying there was a problem, and I want the button to first, destroy the window and the script to close.

Here's my code for this window:

    if enter_key == "":
        sleep(0.5)
        print("\nNo license were entered.")
        popup = ctk.CTkToplevel()
        popup.geometry("300x200")
        label = ctk.CTkLabel(popup, text="No license were entered.", text_color="white", font=("Arial", 16))
        label.pack(pady=20)
        ok_button = ctk.CTkButton(popup, text="OK", command=popup.destroy())
        ok_button.pack(pady=10)

        popup.mainloop()

        time.sleep(2)
        return False

I want to include a quit() when the OK button is pressed, I tried different things but nothing seems to work

torn patioBOT
#

@sour dirge

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

merry swift
#

it expects a function object, not a call

sour dirge
#

what do I do then?

#

nvm I found how

merry swift
#

you also don't need to mainloop the popup

#

and never use time.sleep in a UI

sour dirge
#

I juss added and quit after the command in my button

sour dirge
merry swift
#

you only had to remove the ()

sour dirge
#

also, if I don't use mainloop(), the window doesn't appear

merry swift
#

You shouldn't need it for a toplevel window

#

only the root CTk window

sour dirge
#

well if I don't use it, the window doesn't appear

#

but it's alr I figured everything out

torn patioBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.

#

๐Ÿ”’ Problem using customTkinter