简体   繁体   中英

Fullscreen terminal output (e.g. on a grid)

I am looking for a way or a library to output text to the full screen of the terminal. Ideally, I want to be able to divide the full terminal screen into a grid and then be able to set the output of any cell. In particular, I want to use this functionality to output ongoing calculation progress of several threads/process in a single screen.

I have seen a few libraries that implement TUIs or CUIs (like urwid, npyscreen, python-prompt-toolkit and curtsies) but they seem overly complicated for what I need; they implement widgets and UI controls. They are also geared toward a dialog-like application, ie, they take control of the program flow and the application is expected to respond to user input.

Is there a simple library out there that does what I need?

I don't know if I understood the question correctly, but would it be something like that?

https://pypi.org/project/ebx-printbox/

import ebx_printbox
from multiprocessing import Process
from time import sleep
import os

lst_ObjBox = []
lst_Process = []

# Box(Line:30, Column: 10 to Line: 40, Column: 100 - No Border, Clear Screen)
lst_ObjBox.append(ebx_printbox.pyBox(30, 10, 40, 100, False, True))
lst_ObjBox[0].create_box()

# Box(Line:10, Column: 70 to  Line: 25, Column: 120 - With Border, No Clear Screen)
lst_ObjBox.append(ebx_printbox.pyBox(10, 70, 25, 120, True, False))
lst_ObjBox[1].create_box()


def multi_Box(int_Box):
    for i in range(50):
        lst_ObjBox[int_Box].box_print('Texto: ' + str(i) + ' - Process: ' + str(
            os.getpid()) + ' Lorem ipsum dolor sit amet, ad suas sale eam, falli suavitate corrumpit an sit. Latine '
                           'viderer ex vis. Ex maiorum fuisset aliquando vix, in cum dicant gloriatur. Ei elit '
                           'argumentum cum, quod blandit an eum.')
        sleep(1)  # Time in seconds.


for index in range(2):
    obj_Process = Process(target=multi_Box, args=(index,))
    lst_Process.append(obj_Process)
    obj_Process.start()

# Exit the completed processes
for obj_Process in lst_Process:
    obj_Process.join()

https://asciinema.org/a/414012

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM