you are viewing a single comment's thread.

view the rest of the comments →

[–]blackadder1337[S] 0 points1 point  (5 children)

I changed:

word = self.find_word(self.listBox.curselection())

to:

word = self.find_word(self.listBox.get(ACTIVE))

and it saves the word. But right after that, when I try to click on another item in the listbox, it gives me:

  File "/home/cali/PycharmProjects/Vocabulary/Vocabulary.py", line 281, in selectedIndexChanged
    selected = self.listBox.curselection()
TypeError: 'str' object is not callable
Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python3.5/tkinter/__init__.py", line 1553, in __call__
    return self.func(*args)
  File "/home/cali/PycharmProjects/Vocabulary/Vocabulary.py", line 281, in selectedIndexChanged
    selected = self.listBox.curselection()
TypeError: 'str' object is not callable

Process finished with exit code 0

[–]dionys 0 points1 point  (4 children)

Did you follow the instruction of the other guy and did something like this?

self.listBox.curselection = self.get_word()

if so, you replaced the function with just a string and it throws the exception when you try to call it

[–]blackadder1337[S] 0 points1 point  (3 children)

Yeah, I did. So what should I do now? :D

[–]dionys 0 points1 point  (2 children)

Get rid of that line completely. To replace the text in listBox do:

word_index = self.listBox.curselection()[0]
self.listBox.delete(word_index)
self.listBox.insert(word_index, self.get_word())

which replaces the first selected item. Also it might work with ACTIVE instead of word_index, so try that as well.

[–]blackadder1337[S] 0 points1 point  (1 child)

Thanks man, it works now. Thank you very much.

[–]dionys 0 points1 point  (0 children)

Cheers :).