La línea de comandos se desordenó después de ejecutar un programa Python

El siguiente código crea un diseño y muestra algo de texto en el diseño. A continuación, el diseño se muestra en la pantalla de la consola utilizando el módulo de visualización sin formato delUrwid biblioteca. (Se puede obtener más información sobre mi proyecto completo a partir de las preguntas enWidgets necesarios para mostrar una aplicación de consola 1D yUsando Urwid para crear una aplicación de consola 2D.

Mi petición de ayuda por skype esaquí. Puedo ejecutar el código para mostrar la información relevante. Al presionarF8 El código le pide un diálogo en pantalla si desea salir. Al presionar la tecla 'y', la aplicación finaliza. Pero justo después de que el comando de comando está en mal estado. No puedo escribir nada en el símbolo del sistema. Presionando elEntrar El botón solo repite el símbolo del sistema de la siguiente manera:

[gehna@localhost urwidFormBrowser]$ [gehna@localhost urwidFormBrowser]$ [gehna@localhost urwidFormBrowser]$

El código es:

#!/usr/bin/env python

import sys
sys.path.append('./lib')
import os
from pprint import pprint
import random
import urwid
ui = urwid.raw_display.Screen()

class FormDisplay(object):

    def __init__(self):
        global ui
        #self.ui = urwid.raw_display.Screen()
        self.ui = ui
        self.palette = self.ui.register_palette([
            ('Field', 'dark green, bold', 'black'), # information fields, Search: etc.
            ('Info', 'dark green', 'black'), # information in fields
            ('Bg', 'black', 'black'), # screen background
            ('InfoFooterText', 'white', 'dark blue'), # footer text
            ('InfoFooterHotkey', 'dark cyan, bold', 'dark blue'), # hotkeys in footer text
            ('InfoFooter', 'black', 'dark blue'),  # footer background
            ('InfoHeaderText', 'white, bold', 'dark blue'), # header text
            ('InfoHeader', 'black', 'dark blue'), # header background
            ('BigText', RandomColor(), 'black'), # main menu banner text
            ('GeneralInfo', 'brown', 'black'), # main menu text
            ('LastModifiedField', 'dark cyan, bold', 'black'), # Last modified:
            ('LastModifiedDate', 'dark cyan', 'black'), # info in Last modified:
            ('PopupMessageText', 'black', 'dark cyan'), # popup message text
            ('PopupMessageBg', 'black', 'dark cyan'), # popup message background
            ('SearchBoxHeaderText', 'light gray, bold', 'dark cyan'), # field names in the search box
            ('SearchBoxHeaderBg', 'black', 'dark cyan'), # field name background in the search box
            ('OnFocusBg', 'white', 'dark magenta') # background when a widget is focused
           ])
    urwid.set_encoding('utf8')

    def main(self):
        global ui
        #self.view = ui.run_wrapper(formLayout)
        self.ui.start()
        self.view = formLayout()
        self.exit_view = formLayoutExit()
        self.loop = urwid.MainLoop(self.view, self.palette, unhandled_input=self.unhandled_input)
        self.loop.widget = self.view
        self.loop.run()

    def unhandled_input(self, key):
        if key == 'f8':
            self.loop.widget = self.exit_view
            return True
        if self.loop.widget != self.exit_view:
            return
        if key in ('y', 'Y'):
            raise urwid.ExitMainLoop()
        if key in ('n', 'N'):
            self.loop.widget = self.view
            return True

def formLayout():
    global ui
    text1 = urwid.Text("Urwid 3DS Application program - F8 exits.")
    text2 = urwid.Text("One mission accomplished")
    textH = urwid.Text("topmost Pile text")
    cols = urwid.Columns([text1,text2])
    pile = urwid.Pile([textH,cols])
    fill = urwid.Filler(pile)

    textT  = urwid.Text("Display")

    textSH = urwid.Text("Pile text in Frame")
    textF = urwid.Text("Good progress !")

    frame = urwid.Frame(fill,header=urwid.Pile([textT,textSH]),footer=textF)
    dim = ui.get_cols_rows()
    #ui is treated as global handle for all functions, either belonging
    #to any class or standalone functions such as formLayout
    #need to check if screen has been started
    if not ui._started:
        print("Screen has not been started, so no use of rendering.Thus return :-( ")
        return

    ui.draw_screen(dim, frame.render(dim, True))
    return frame


def formLayoutExit():
    exit = urwid.BigText(('exit'," Quit? "), urwid.font.HalfBlock5x4Font())
    exit = urwid.Overlay(exit, formLayout(), 'center', None, 'middle', None)
    return exit

def RandomColor():
    '''Pick a random color for the main menu text'''
    listOfColors = ['dark red', 'dark green', 'brown', 'dark blue',
                    'dark magenta', 'dark cyan', 'light gray',
                    'dark gray', 'light red', 'light green', 'yellow',
                    'light blue', 'light magenta', 'light cyan', 'default']
    color = listOfColors[random.randint(0, 14)]
    return color

def main():
    #global ui
    form = FormDisplay()
    form.main()

########################################
##### MAIN ENTRY POINT
########################################
if __name__ == '__main__':
    main()

Sospecho que el comportamiento mostrado después de que la aplicación sale tiene que hacer algo con las llamadas de retorno de las funciones FormDisplay, formlayout y formlayoutExit. ¿Como puedo solucionar este problema?