Hello,
Here is an example to get you started:
python code
menu_entries = ['Entry 1', 'Entry 2', 'Entry 3']
class ListButtonListener(ix.api.EventObject):
def __init__(self, list_button):
""" Constructor"""
# init parent class EventObject
ix.api.EventObject.__init__(self)
# store the button we are connecting to so that we can reference it later
self.list_button = list_button
# connect the listener (self) to the list selection change event
self.connect(self.list_button, 'EVT_ID_LIST_BUTTON_SELECT', self.on_list_item_selected)
def on_list_item_selected(self, sender, event_id):
"""Event handler for the list button"""
selected_index = self.list_button.get_selected_item_index()
selected_label = self.list_button.get_selected_item_name()
print('Selected entry is: index = {}, label = "{}"'.format(selected_index, selected_label))
def show_custom_gui():
# create the parent window
window = ix.api.GuiWindow(ix.application, 0, 0, 400, 300, "List Button Test")
# create the list button and the entries
list_button = ix.api.GuiListButton(window, 0, 0, 200, 20)
for i, entry in enumerate(menu_entries):
# select the 1st and set the others unselected
selected = True if i == 0 else False
list_button.add_item(entry, selected)
# init list button listener
list_listener = ListButtonListener(list_button)
# show the window and loop until closed
window.show()
while window.is_shown():
ix.application.check_for_events()
# Run it
show_custom_gui()
GuiListButton documentation:
https://www.clarissewiki.com/4.0/sdk/cl ... utton.htmlCheers,