bczsalba / pytermgui

Python TUI framework with mouse support, modular widget system, customizable and rapid terminal markup language and more!
https://ptg.bczsalba.com
MIT License
2.25k stars 56 forks source link

[HOWTO] How can I use the terminal widget? #139

Closed agoodfellow123 closed 7 months ago

agoodfellow123 commented 8 months ago

I want to create an environment like the Twin Terminal Window Manager for that I must understand how to use the terminal widget, I'm trying to spawn it with:

from pytermgui import WindowManager, Window, Terminal, widgets

manager = WindowManager()
terminal = widgets.Widget.terminal
window = (terminal)
manager.add(terminal)
manager.run()

however unfortunately that just gives me the AttributeError: 'property' object has no attribute 'manager' error. Can you please explain step by step what I'm doing wrong?

tritium21 commented 7 months ago

There is no terminal widget. What you have attempted to use as a widget is an object (named terminal) that contains information about your terminal. The object tells PyTermGui how to interact with your terminal (xterm, windows terminal, etc.) - it does not allow you to host a terminal.

bczsalba commented 7 months ago

As @tritium21 said, the Terminal object is an interface to the terminal emulator PTG is running in - not an emulator itself. Creating a multiplexer (which is what you're looking for I think) with PTG is possible, though far from trivial. I've collected some SO sources for it for a different project, so if you're interested these are a starting point: