CustomTkinter
CustomTkinter copied to clipboard
CTkButton.configure(border_width=) causes exception
CustomTkinter 4.6.3
Adding this third line to simple_example.py:
button_1 = customtkinter.CTkButton(master=frame_1, command=button_callback, border_width=3, width=20, corner_radius=20)
button_1.pack(pady=12, padx=10)
button_1.configure(border_width=3)
Causes exception:
File "/home/clive/PycharmProjects/customtk/simple_example.py", line 30, in <module>
button_1.configure(border_width=3)
File "/home/clive/PycharmProjects/customtk/venv/lib/python3.8/site-packages/customtkinter/widgets/ctk_button.py", line 293, in configure
super().configure(require_redraw=require_redraw, **kwargs)
File "/home/clive/PycharmProjects/customtk/venv/lib/python3.8/site-packages/customtkinter/widgets/widget_base_class.py", line 131, in configure
super().configure(**kwargs)
File "/usr/lib/python3.8/tkinter/__init__.py", line 1646, in configure
return self._configure('configure', cnf, kw)
File "/usr/lib/python3.8/tkinter/__init__.py", line 1636, in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: unknown option "-border_width"
@avalon60 Border_width cannot be changed via configure. You can see the configurable parameters of button here: https://github.com/TomSchimansky/CustomTkinter/blob/master/customtkinter/widgets/ctk_button.py#L238 To change these parameters, we have to use 'button_1.border_width=3`.
Just changing the attributes like button_1.border_width=3
will not change the border because there is more to it than just change the attribute values. The button has to be rendered, and sometimes the grid system must change so that the text label of the button does not overlap the border. So this won't work properly.
But I will add the missing configure and cget attributes.
@avalon60 Border_width cannot be changed via configure. You can see the configurable parameters of button here: https://github.com/TomSchimansky/CustomTkinter/blob/master/customtkinter/widgets/ctk_button.py#L238 To change these parameters, we have to use 'button_1.border_width=3`.
Hi matey. Yes, I raised that as a separate issue. I have been working through the base widget shape properties - the one's required in the theme files. I am guessing you have / or will hit a some of these two. I think I have raised issues for all of them now, at least for CustomTkinter 4.6.
Just changing the attributes like
button_1.border_width=3
will not change the border because there is more to it than just change the attribute values. The button has to be rendered, and sometimes the grid system must change so that the text label of the button does not overlap the border. So this won't work properly.But I will add the missing configure and cget attributes.
Hi Tom. I'm not clear on what the solution is. Does it mean that a fresh call to .grid must be made?
For a change of the border_width you would have to call ._create_grid() and ._draw() at the moment, but this can change at any time.
For a change of the border_width you would have to call ._create_grid() and ._draw() at the moment, but this can change at any time.
A little piece of me just died :disappointed:
Fixed with version 5.0.0.