Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure command on CTkButton #24

Closed
salot18 opened this issue Jan 8, 2022 · 1 comment
Closed

Configure command on CTkButton #24

salot18 opened this issue Jan 8, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@salot18
Copy link

salot18 commented Jan 8, 2022

So I'm trying to change the command of aCTkButton using the configure method, but I'm getting an exception.

Here is the exception:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 1892, in __call__
    return self.func(*args)
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\customtkinter\customtkinter_button.py", line 505, in clicked
    self.function()
  File "c:\Users\User\Desktop\youtube-audio-downloader\tempCodeRunnerFile.py", line 8, in print_hello       
    btn.configure(command=print_bye)
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\customtkinter\customtkinter_button.py", line 443, in configure
    super().configure(*args, **kwargs)
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 1646, in configure
    return self._configure('configure', cnf, kw)
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 1636, in _configure
    self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: unknown option "-command"

And here is my code:

import customtkinter as ctk

root = ctk.CTk()
root.geometry("200x200")

def print_hello():
  print("hello world")
  btn.configure(command=print_bye)

def print_bye():
  print("bye bye world")
  btn.configure(command=print_hello)

btn = ctk.CTkButton(master=root, text="Click Me", command=print_hello)
btn.place(relx=0.5, rely=0.5, anchor="center")

root.mainloop()
@TomSchimansky TomSchimansky added the enhancement New feature or request label Jan 8, 2022
@TomSchimansky
Copy link
Owner

TomSchimansky commented Jan 8, 2022

This functionality simply wasn't implemented yet for the Button, but now I added it and you can change the command with .configure(). It isn't on pip for now but you can also download the customtkinter folder from Github and place it next to your file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants