Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def find_id_by_title(string):
for index,title in enumerate(tabs.titles):
if string in title.original_widget.text:
return tabs.get_id(index)
def find_right_left_id(right_or_left):
tabcount = len(tabs)
if tabcount > 1:
cur_index = tabs.focus_position
cur_index = 1 if cur_index is None else cur_index
if right_or_left == 'left':
return tabs.get_id(max(0, cur_index-1))
elif right_or_left == 'right':
return tabs.get_id(min(tabcount-1, cur_index+1))
index = int(index)
except ValueError:
pass
else:
index_max = len(tabs) - 1
# Internally, first tab is at index 0, but for users it's 1, unless
# they gave us 0, in which case we assume they mean 1.
index = index-1 if index > 0 else index
# Limit index to index_max, considering negative values when
# indexing from the right.
if index < 0:
index = max(index, -index_max-1)
else:
index = min(index, index_max)
return tabs.get_id(index)
def find_right_left_id(right_or_left):
tabcount = len(tabs)
if tabcount > 1:
cur_index = tabs.focus_position
cur_index = 1 if cur_index is None else cur_index
if right_or_left == 'left':
return tabs.get_id(max(0, cur_index-1))
elif right_or_left == 'right':
return tabs.get_id(min(tabcount-1, cur_index+1))