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

Curses menu - Continued #2569

Merged
merged 11 commits into from
Jul 11, 2024
Merged

Conversation

svartkanin
Copy link
Collaborator

Updating new curses menu from previous PR

  • Addressed comments from previous PR
    • Renamed V type variable
    • Changed the instantiation of the Tui() class so that it will not right away kick off curses but requires a tui.init() to avoid issues when tests are importing various modules
  • Added support for text input menu
  • Added scrolling functionality for previews
  • Added support for aligning menus right and center

image
image

The following code produces the above screenshots

from archinstall.tui.curses_menu import SelectMenu, MenuItemGroup, FrameProperties, FrameStyle, EditMenu, tui

tui.init()

def test_data():
	return """{
	"__separator__": null,
	...
	"""

items = [
	MenuItem(f'Language', preview_action=lambda x: test_data()),
	MenuItem(f'Disk configuration', preview_action=lambda x: test_data()),
	MenuItem(f'Install', preview_action=lambda x: test_data()),
	MenuItem(f'Abort', preview_action=lambda x: test_data()),
]

group = MenuItemGroup(items, sort_items=False, focus_item=items[0])


menu = SelectMenu(
	group,
	reset_warning_msg='are you certain?',
	allow_skip=False,
	allow_reset=False,
	preview_style=PreviewStyle.RIGHT,
	# alignment=Alignment.CENTER,
	preview_size='auto',
	preview_frame=FrameProperties('Info', FrameStyle.MAX),
).single()


def validator(value: str):
	import re
	if not re.match(r"^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$", value):
		return 'Specify a valid username'
	return None

username = EditMenu('Username', validator=validator, alignment=Alignment.CENTER).input()

@svartkanin svartkanin requested a review from Torxed as a code owner July 10, 2024 11:10
@svartkanin svartkanin changed the title Curses menu text input Curses menu - Continued Jul 10, 2024
Copy link
Member

@Torxed Torxed left a comment

Choose a reason for hiding this comment

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

Great work!

@Torxed Torxed merged commit b9ab1e2 into archlinux:master Jul 11, 2024
6 checks passed
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.

2 participants