This is an Example how to switch ListEntries for Listboxes
depentend from selected Item in other Boxes.
it derived from this this crumpy thread
with credits to @Villeroy increase Combobox-ListEntrySource
from com.sun.star.beans import NamedValue
def update_other(button):
"""
triggert by Event: 'Modified' of Listbox_button
search for the Named_Range addressed by actually selected Item,
and updates 'other_button's ListEntrySource to the name_range…RangeAddress
with credits to @ Villeroy:
https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=65127&p=289137&hilit=+ListEntrySource#p289074"
"""
OTHERBUTTON = "List Box 2"
control = button.Source
item = control.SelectedItem
controls = control.Model.Parent
doc = controls.Parent.Parent
named_ranges = doc.NamedRanges
name_range = named_ranges.getByName(item)
name_val = NamedValue()
name_val.Name = "CellRange"
name_val.Value = name_range.ReferredCells.RangeAddress
list_source = doc.createInstance("com.sun.star.table.CellRangeListSource")
list_source.initialize((name_val,))
for chield in controls:
if chield.Name == OTHERBUTTON:
chield.setListEntrySource(list_source)
return