I have created a simple gui with curses. However, when the curses menu is finished the print function does not print anything to screen until the main program exits.
In the example below, when calc.py is run, the text "Directory list ok" is printed to the screen after the foo(calcDirs) is run. If I comment out the line folderSelection.menu(dirs)
the text is printed to the screen as it normally would. Any ideas? I use python 2.5
calc.py:
import folderSelection
[...]
calcDirs=folderSelection.menu(dirs)
print "Directory list ok"
foo(calcDirs)
folderSelection.py:
import curses
def menu(folders):
global scr
scr = curses.initscr()
curses.noecho() # Do not echo keypresses
curses.cbreak() # No enter required
scr.keypad(1) # Support keypad
curses.curs_set(0) # Do not show the cursor
# Do some calculations
[...]
exitCurses()
return calcDirs
def exitCurses():
global scr
curses.nocbreak()
curses.curs_set(1)
scr.keypad(0)
curses.echo()
curses.endwin()
Edit: It seems that the text is necessarily delayed until the program terminates. It may just be delayed some 30-40 seconds.