Skip to content
Myr

Added some examples to termui for getchar and pause

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent d182acf · Browse files · 1 file+34 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+34 added−0 removed

  • other:+34 added−0 removed

1 file+34 added−0 removed

modified:examples/termui/termui.py+34 added
107 unmodified lines
108@cli.command()109def clear():110 """Clears the entire screen."""111 click.clear()112113114@cli.command()115def pause():116 """Waits for the user to press a button."""117 click.pause()118119120@cli.command()121def menu():122 """Shows a simple menu."""123 menu = 'main'124 while 1:125 if menu == 'main':126 click.echo('Main menu:')127 click.echo(' d: debug menu')128 click.echo(' q: quit')129 char = click.getchar()130 if char == 'd':131 menu = 'debug'132 elif char == 'q':133 menu = 'quit'134 else:135 click.echo('Invalid input')136 elif menu == 'debug':137 click.echo('Debug menu')138 click.echo(' b: back')139 char = click.getchar()140 if char == 'b':141 menu = 'main'142 else:143 click.echo('Invalid input')144 elif menu == 'quit':145 return