Akascape / CTkListbox

A simple listbox for customtkinter (extenstion/add-on)
MIT License
130 stars 14 forks source link

Select function broke after last update #49

Closed infiniteTesch closed 2 months ago

infiniteTesch commented 4 months ago

Got this error after the last update when trying to click on items in my listbox which is popualated with basic string references to .txt files. Neither .activate() or regular select works.

C:\noyb\projects\studd\lists\.txt Sort File not found: C:\noyb\projects\studd\lists\.txt Error opening file: [Errno 22] Invalid argument: 'C:\noyb\projects\studd\lists\.txt'

self.listbox = EditorListbox(self.bottom_frame, command=self.on_listbox_select)

class EditorListbox(CTkListbox): def init(self, master, command=None, **kwargs)

    self.command = command

    self.bind("<<ListboxSelect>>", self.on_listbox_select)

def unbind(self):
    self.unbind_all("<<ListboxSelect>>")

def update_theme(self):
    self.configure(
        fg_color=listbox_fg_color, 
        highlight_color=listbox_select_color,  
        border_color=listbox_border_color, 
        hover_color=listbox_select_color,
        text_color = listbox_txt_color,
        scrollbar_button_color=scrollbar_color,
        scrollbar_button_hover_color=scrollbar_hover_color
    )

def on_listbox_select(self, event):
    if self.command:
        self.command(event)
infiniteTesch commented 4 months ago

I made it work by using the .get() function instead of selection_option like so: def on_listbox_select(self, selected_option):

In this case i got VirtualEvent event x=0 y=0 as value for selected_option on click.

Akascape commented 2 months ago

@infiniteTesch <<ListboxSelect>> is only a trigger event which doesn't return/pass any value, you have to use .get() method in the function with this.