#๐Ÿ”’ Custom TKinter

16 messages ยท Page 1 of 1 (latest)

light lintel
#
class App(CTk):
    def __init__(self):
        super().__init__()
        self.title("App")
        self.geometry("900x700")

        self.login_frame = customtkinter.CTkFrame(self, corner_radius=10, width=400, height=250)
        self.login_frame.pack(padx=150, pady=150)

        self.bg_image = customtkinter.CTkImage(Image.open("C:\\Users\\Ayman\\download.png"), size=(900, 700))
        image = customtkinter.CTkEntry(self.login_frame,
                                            placeholder_text='Enter email...',
                                            width=400, height=30, border_width=2, corner_radius=5, text_color='black',
                                            image=self.bg_image)
        image_button.pack()```

I had a email and password entry that was working normally, but i wanted to add an image and it broke everything so i tried to add the entry into the image and now im getting an error:

```File "C:\Users\Ayman\PycharmProjects\pythonProject2\setup.py", line 18, in __init__
    image_button = customtkinter.CTkEntry(self.login_frame,
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Ayman\PycharmProjects\pythonProject2\venv\Lib\site-packages\customtkinter\windows\widgets\ctk_entry.py", line 93, in __init__
    check_kwargs_empty(kwargs, raise_error=True)
  File "C:\Users\Ayman\PycharmProjects\pythonProject2\venv\Lib\site-packages\customtkinter\windows\widgets\utility\utility_functions.py", line 18, in check_kwargs_empty
    raise ValueError(f"{list(kwargs_dict.keys())} are not supported arguments. Look at the documentation for supported arguments.")
ValueError: ['image'] are not supported arguments. Look at the documentation for supported arguments.```
solemn timberBOT
#

@light lintel

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.

sour heron
#

Looks like image isn't one of the arguments CtkEntry accepts https://github.com/TomSchimansky/CustomTkinter/wiki/CTkEntry#arguments

If you're trying to create a text box with a background image, my best guess for how to accomplish that (it's been a moment since I messed with tkinter/customtkinter) would be to create a frame with the image, then put a text box with a transparent background in the frame

GitHub

A modern and customizable python UI-library based on Tkinter - TomSchimansky/CustomTkinter

light lintel
#

@sour heron everything gets squashed to the bottom

#

without the background

sour heron
#

Hmm, would you mind pasting the updated code?

light lintel
#
customtkinter.set_appearance_mode("light")


class App(CTk):
    def __init__(self):
        super().__init__()
        self.title("App")
        self.geometry("900x700")

        self.bg_image = customtkinter.CTkImage(Image.open("C:\\Users\\Ayman\\download.png"), size=(900, 700))
        image_button = customtkinter.CTkLabel(self,
                                               text="",
                                               image=self.bg_image)
        #image_button.pack()

        def change():
            val = self.switch.get()
            if val:
                customtkinter.set_appearance_mode("dark")
            else:
                customtkinter.set_appearance_mode("light")

        # Assuming CTkSwitch is a custom widget from your customtkinter module
        self.switch = CTkSwitch(self, text='Dark Mode',
                                onvalue=1,
                                offvalue=0,
                                command=change)
        self.switch.place(relx=0.84, rely=0.01)

        # Assuming CTkLabel, CTkFrame, and CTkEntry are correctly implemented in customtkinter
        self.loginlabel = customtkinter.CTkLabel(self, text="Log In", font=('Arial', 20))
        self.loginlabel.pack(pady=10)

        self.login_frame = customtkinter.CTkFrame(self, corner_radius=10, width=400, height=250)
        self.login_frame.pack(padx=150, pady=150)

        self.email = customtkinter.CTkEntry(self.login_frame, placeholder_text='Enter email...',
                                            width=400, height=30, border_width=2, corner_radius=5, text_color='black')
        self.email.pack(pady=10)

        self.password = customtkinter.CTkEntry(self.login_frame, placeholder_text='Enter password...',
                                               width=400, height=30, border_width=2, corner_radius=5,
                                               text_color='black')
        self.password.pack(pady=10)
#

hashed the image pack just for now

sour heron
#

Sorry for the delay. Are you wanting the "Log In" text to be on top of the image?

light lintel
light lintel
solemn timberBOT
#
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.