1

I have a problem. You see, I've created this simple chat server. On the client side, since its a chat server, I'm continuously asking the user for input. The thing is, my input prompt is ">", and if you see in the picture below, it gets meshed with all the messages being printed (in this case behind the message sent by the client) My question is, can I make it so that the prompt ">" is always at the bottom/new line of the terminal? Console Example

Max K
  • 65
  • 7
  • In a single terminal window? – jonrsharpe Aug 11 '15 at 14:51
  • @jonrsharpe yes sorry I'll edit my post – Max K Aug 11 '15 at 14:53
  • Do you know curses? https://docs.python.org/3/howto/curses.html – spectras Aug 11 '15 at 14:55
  • @spectras I'm using Python 2 for my chat server. Basically I made a library that uses a protocol I made to exchange basic packets and I wrote it in Python 2.7.10 since most other libraries havent been updated past 2.7.10 allowing my library to be used for more purposes – Max K Aug 11 '15 at 14:58
  • Alright then, do you know curses? https://docs.python.org/2/howto/curses.html - I see someone wrote you a proper answer with a breakdown of the available options. – spectras Aug 11 '15 at 15:01

1 Answers1

3

There are several options:

  • You can write a simple version using ANSI escape sequences yourself, but this will quickly become a pain.
  • You can use the curses module from the standard library, which abstracts away the specifics of inidividual terminals, and is less of a pain than trying to use escape sequences only.
  • You can use a higher level framework built on top of curses, like urwid or npyscreen.

I'd personally go with the last option.

Sven Marnach
  • 574,206
  • 118
  • 941
  • 841