祝福:如何在退出时将光标移动到屏幕底部?(Blessings: how to move cursor to bottom of screen on exit?)

编程入门 行业动态 更新时间:2024-10-27 21:13:06
祝福:如何在退出时将光标移动到屏幕底部?(Blessings: how to move cursor to bottom of screen on exit?)

我正在尝试Python脚本的一些光标图形输出,为我的应用程序提供了一个很好的进度条。

在显示输出之前,我使用以下内容确保我的屏幕为空白。

print term.clear

但是当我的Python脚本完成时,我的shell提示符会在屏幕顶部输出,覆盖部分进度条。

当Python脚本退出时,如何将光标移动到我的图形输出下方? 我在退出脚本之前尝试过这个:

print term.move(0, term.height-1)

但这似乎被忽略了。 我的shell开始在屏幕顶部输出。

我不想进入全屏模式,我想在脚本完成后将进度条的最终输出留在屏幕上。

我的环境是:

OS X 10.10终端处于xterm-256模式。 Python 2.7.10 祝福1.6

I'm trying out some cursor-graphical output of a Python script, to give my app a nice progress bar.

I use the following to ensure my screen is blank before displaying output.

print term.clear

But when my Python script finishes, my shell prompt is output at the top of the screen, overwriting part of the progress bar.

How can I move the cursor to below my graphical output as the Python script exits? I have tried this right before exiting the script:

print term.move(0, term.height-1)

But this seems to be ignored. My shell begins output at the top of the screen.

I don't want to enter fullscreen mode, I'd like to leave the final output of the progress bar on the screen after the script finishes.

My environment is:

OS X 10.10 Terminal in xterm-256 mode. Python 2.7.10 Blessings 1.6

最满意答案

我认为你有向后的term.move()参数(基于这里的“永久移动”部分)。

move() Parameters are y coordinate, then x coordinate.

尝试这个:

print term.move(term.height - 1, 0)

I think you have the arguments to term.move() backwards (based on the "Moving Permanently" section here).

move() Parameters are y coordinate, then x coordinate.

Try this:

print term.move(term.height - 1, 0)

更多推荐

本文发布于:2023-07-30 01:24:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1321359.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:光标   时将   屏幕   如何在   Blessings

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!