Skip to main content

Small print tool for implementing chat in the terminal.

https://pypi.org/project/print_chat/

Usage example

import print_chat as pc

pct = pc.print_chat()

sender = 'Charls'
pct.set_colors([('Charls', 'green')])

while True:
    post = str(input('> '))

    if post == 'exit':
        break
    else:
        pct.up_on_occupied_rows(len(post) + len(sender) + 2)
        pct.add_message('Charls', post)

pct.close()

For testing the main functionality:

import print_chat as pc

pct = pc.print_chat(time=True)

s = 0 # sender iterator
senders = ['Charls', 'Max', 'Karl']
pct.set_colors([
        (senders[0], 'green'),
        (senders[1], 'red'),
        (senders[2], 'yellow')
    ])
pct.set_header('-Test chat-\n-----------') # adding a header to the dialog

while True:
    post = str(input('> '))
    pct.up_on_occupied_rows(len(post) + len(senders[s]) + 2)
    command = post.split(' ')

    if post == 'exit':                  break
    elif command[0] == 'remove':        pct.remove(int(command[1]))
    elif command[0] == 'edit':          pct.edit(int(command[1]), ' '.join(command[2:]))
    elif command[0] == 'reload':        pct.reload(int(command[1]))
    elif command[0] == 'add_skip':      pct.add_skip(int(command[1]), str(' '.join(command[2:])))
    elif command[0] == 'edit_skip':     pct.edit_skip(int(command[1]), ' '.join(command[2:]))
    elif command[0] == 'remove_skip':   pct.remove_skip(int(command[1]))
    elif command[0] == 'add_mark':      pct.add_mark(int(command[1]), str(command[2]))
    elif command[0] == 'edit_mark':     pct.edit_mark(int(command[1]), str(command[2]))
    elif command[0] == 'remove_mark':   pct.remove_mark(int(command[1]))
    elif post == 'cs':                  s = (s+1) % len(senders) # change sender to next
    else:                               pct.add_message(senders[s], post)

pct.close()

Important

Numbering starts at 1, at the end of the message list

This is not a bug this is a feature

Create object

default:

pct = print_chat.print_chat(time=False)
  • time - show message sending time

Method list

  • .add_message(sender, text, time=’’, skip=[], mark=[])

  • .add_message_top(sender, text, time=’’, skip=[], mark=[], prnt=True)

  • .reload(number)

  • .remove(number)

  • .edit(number, text)

  • .add_skip(number, text)

  • .edit_skip(number, text)

  • .remove_skip(number)

  • .add_mark(number, text)

  • .edit_mark(number, text)

  • .remove_mark(number)

  • .close(clr) - closes the dialog, with or without screen clearing

  • .set_header(string)

  • .set_colors(colors) - takes a list [[sender, color],..]
    colors list:
    • grey

    • red

    • green

    • yellow

    • blue

    • magenta

    • cyan

    • white

  • .get_num_messages() - returns the number of messages

  • .get_messages()

  • .get_messages_from(sender)

  • .up_on_occupied_rows(len_str)

  • .up_on_message(number)

  • .up_on_rows(number)

  • .clear_row()

  • ._clear_screen()

  • .get_senders() - returns a list of dictionaries

Installation

$ pip install print_chat

or

Repository cloning

$ git clone https://github.com/IVIGOR13/print_chat.git

Tuning

$ pip install termcolor
$ pip install colorama

Metadata

Release files for print-chat 0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for print-chat 0.4
File Size Uploaded Provenance Actions
print_chat-0.4.tar.gz 6.8 kB Without provenance Details for print_chat-0.4.tar.gz

Security for print-chat 0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.4 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page