-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnc_input.py
More file actions
38 lines (29 loc) · 965 Bytes
/
nc_input.py
File metadata and controls
38 lines (29 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python
#TUI curses test/example
import curses
def calculate(a, b, c):
return a + b + c
def main(stdscr):
# Initialize the curses object
stdscr = curses.initscr()
# Set the mode of the terminal to non-blocking or cbreak mode
curses.cbreak()
# Do not echo keys back to the client
curses.noecho()
# Get parameters a, b, and c from the user
stdscr.addstr(0, 0, "Enter parameter a: ")
a = int(stdscr.getstr().decode('utf-8'))
stdscr.addstr(1, 0, "Enter parameter b: ")
b = int(stdscr.getstr().decode('utf-8'))
stdscr.addstr(2, 0, "Enter parameter c: ")
c = int(stdscr.getstr().decode('utf-8'))
# Call the function with the parameters
result = calculate(a, b, c)
# Display the result
stdscr.addstr(4, 0, "Result: " + str(result))
# Wait for the user to press a key
stdscr.getch()
# Deinitialize the curses mode
curses.endwin()
if __name__ == "__main__":
curses.wrapper(main)