pythonnpyscreen

Display properly output messages using npyscreen


I have an script that collects initial information using npyscreen and then display multiple messages as it progresses. However, these messages are displayed in an unorganized way (see below). Is there a way to populate those messages in the correct way (without tabs)?

Something
         Something
                  Something

This is the code

import npyscreen, time

class Test(npyscreen.NPSApp):
    def main(self):

        F  = npyscreen.Form(name = "Test")

        color = F.add(npyscreen.TitleText, name = "Color:")
        
        F.edit()        

        if(color.value == "Something"):
            self.call_function_to_display_messages(color.value)


    def call_function_to_display_messages(self, color):

        print(color)
        print(color)
        print(color)
        time.sleep(10)

if __name__ == "__main__":
    App = Test()
    App.run()

Solution

  • The solution is to add the carriage return at the beginning the of print statement.

    print("\r"+color)