Skip to content
New issue

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

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

Already on GitHub? # to your account

empty StringVar raise error and cannot create CTkListbox with listvariable #62

Open
sliweq opened this issue May 9, 2024 · 1 comment

Comments

@sliweq
Copy link

sliweq commented May 9, 2024

s = ctk.StringVar()
self.logs_list = CTkListbox(master=self,listvariable = s)

rasie:

File ".../main.py", line 95, in init
self.logs_list = CTkListbox(master=self,listvariable = s)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../CTkListbox/ctk_listbox.py", line 91, in init
self.update_listvar()
File ".../CTkListbox/ctk_listbox.py", line 94, in update_listvar
values = list(eval(self.listvariable.get()))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 0
SyntaxError: invalid syntax

And
s = ctk.StringVar()
s.set([1,2,3,4])
self.logs_list = CTkListbox(master=self,listvariable = s)

listbox from tkinter works fine also with list of string. I've tried also set and dict. Both didnt worked

raise:

File ".../main.py", line 95, in init
self.logs_list = CTkListbox(master=self,listvariable = s)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../CTkListbox/ctk_listbox.py", line 91, in init
self.update_listvar()
File ".../CTkListbox/ctk_listbox.py", line 95, in update_listvar
self.delete("all")
File ".../CTkListbox/ctk_listbox.py", line 260, in delete
self.deactivate("all")
File ".../CTkListbox/ctk_listbox.py", line 188, in deactivate
self.deselect(0)
File ".../CTkListbox/ctk_listbox.py", line 178, in deselect
if self.buttons[index] in self.selections:
~~~~~~~~~~~~^^^^^^^
KeyError: 0

@djk1983
Copy link

djk1983 commented Dec 28, 2024

I had the same issue. I implemented the proposed pull request from https://github.com/andreyvorobyov2 #69 which resolved it.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants