Is there a way to interactively program a Python curses application?

前端 未结 3 1466
盖世英雄少女心
盖世英雄少女心 2020-12-30 05:47

Is there a way to create a second terminal so that all calls to curses functions operate on that, rather than in the existing terminal? I work much faster when

3条回答
  •  抹茶落季
    2020-12-30 06:28

    Well, I'm not sure I understand completly what you're trying to do. But what I've understood is this that you want to have a standard python console where you can type your code dynamically. But when you call, for exemple a function, the output of the processing of this function would appear into another terminal?

    Well... for it to work, I think the architecture to use would be a "client-server".

    Because a process has an stdout and a stderr, and in a multiprocessing architecture you could use the stderr as the function's output pipe. But the problem is initializing the other terminal that is separated from the main one. (no overlapping inside the same space).

    If your main program Initialize a Server (on another Python process, because of the nature itself of a server) which sends the output to all client connected to it. This way you could visualize the function's output on several terminal clients and/or another computer able to connect to your server.

    It is, at my opinion, much easier than trying to use the 'curses' package. But if the only purpose is to gain an insight of your code, I think it's overcomplicated (no added value).


    You still have the option of dumping the function's output into a text file (log.txt)

提交回复
热议问题