CustomTkinter icon indicating copy to clipboard operation
CustomTkinter copied to clipboard

CTkButton.configure(border_width=) causes exception

Open avalon60 opened this issue 1 year ago • 6 comments

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 avatar Nov 03 '22 08:11 avalon60

@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`.

Akascape avatar Nov 03 '22 09:11 Akascape

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.

TomSchimansky avatar Nov 06 '22 12:11 TomSchimansky

@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.

avalon60 avatar Nov 08 '22 10:11 avalon60

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?

avalon60 avatar Nov 08 '22 10:11 avalon60

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.

TomSchimansky avatar Nov 08 '22 10:11 TomSchimansky

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:

avalon60 avatar Nov 08 '22 12:11 avalon60

Fixed with version 5.0.0.

TomSchimansky avatar Dec 02 '22 12:12 TomSchimansky