Files
Castello/prove.py
2026-01-24 10:44:33 +00:00

40 lines
1.3 KiB
Python
Executable File

import curses
import curses.textpad
def main(screen):
# Inizializza la libreria curses
curses.curs_set(0)
curses.init_pair(1, curses.COLOR_CYAN, curses.COLOR_BLACK)
curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_CYAN)
curses.init_pair(3, curses.COLOR_WHITE, curses.COLOR_RED)
screen.clear()
screen.refresh()
# Crea la prima finestra
win1 = curses.newwin(5, 40, 5, 10)
win1.box()
win1.addstr(1, 1, "Inserisci il tuo nome:", curses.color_pair(1))
textbox1 = curses.textpad.Textbox(win1)
textbox1.edit()
win1.clear()
win1.addstr(1, 1, "Il tuo nome è: " + textbox1.gather(), curses.color_pair(2))
win1.addstr(3, 1, "Premi un tasto per uscire", curses.color_pair(1))
win1.refresh()
# Crea la seconda finestra
win2 = curses.newwin(5, 40, 12, 10)
win2.box()
win2.addstr(1, 1, "Inserisci il tuo cognome:", curses.color_pair(1))
textbox2 = curses.textpad.Textbox(win2)
textbox2.edit()
win2.clear()
win2.addstr(1, 1, "Il tuo cognome è: " + textbox2.gather(), curses.color_pair(2))
win2.addstr(3, 1, "Premi un tasto per uscire", curses.color_pair(1))
win2.refresh()
# Attendi l'input dell'utente per uscire
curses.curs_set(1)
screen.getch()
if __name__ == '__main__':
curses.wrapper(main)