Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tabs widget #2020

Merged
merged 31 commits into from
Mar 13, 2023
Merged

tabs widget #2020

merged 31 commits into from
Mar 13, 2023

Conversation

willmcgugan
Copy link
Collaborator

@willmcgugan willmcgugan commented Mar 11, 2023

Adds a Tabs widget.

This will form part of a larger TabbedContent widget, but could be used independently.

Screenshot 2023-03-13 at 11 11 36

Screen.Recording.2023-03-13.at.11.21.32.mov

@willmcgugan willmcgugan marked this pull request as draft March 11, 2023 10:43
@willmcgugan willmcgugan changed the title WIP tabs widget tabs widget Mar 13, 2023
@willmcgugan willmcgugan marked this pull request as ready for review March 13, 2023 11:21
docs/api/tabs.md Outdated Show resolved Hide resolved
docs/guide/actions.md Outdated Show resolved Hide resolved
docs/widgets/tabs.md Outdated Show resolved Hide resolved
docs/widgets/tabs.md Outdated Show resolved Hide resolved
docs/widgets/tabs.md Outdated Show resolved Hide resolved
src/textual/widgets/_tabs.py Outdated Show resolved Hide resolved
Comment on lines +228 to +236
del tabs[active_index]
try:
return tabs[active_index]
except IndexError:
try:
return tabs[active_index - 1]
except IndexError:
pass
return None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is something I don't get. Can't we just do this by inspecting the length of tabs with respect to the active_index?
Why do we have to del tabs[active_index] and whatnot?

Does del tabs[active_index] do anything other than deleting that specific entry from the list tabs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure there is a more elegant solution. But we want to get the next active tab, which is normally the one to the right. Unless we're at the end, then its the one to the left.

src/textual/widgets/_tabs.py Show resolved Hide resolved
src/textual/widgets/_tabs.py Outdated Show resolved Hide resolved
src/textual/widgets/_tabs.py Outdated Show resolved Hide resolved
@willmcgugan willmcgugan merged commit b0f5c35 into main Mar 13, 2023
@willmcgugan willmcgugan deleted the tabs-widget branch March 13, 2023 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants