简体   繁体   English

Clear和exit_fullscreen似乎不起作用

[英]Clear and exit_fullscreen seem not to work

I've started to play around with blessings - so far I'm liking it a lot since it does make things a lot easier. 我开始玩祝福了 - 到目前为止,我很喜欢它,因为它确实让事情变得容易多了。 However I tried to clear the screen without success... enter_fullscreen seems to work tho since that "clears" it - but exit_fullscreen doesn't bring me back to the original view. 然而,我试图清除屏幕没有成功... enter_fullscreen似乎工作,因为“清除”它 - 但exit_fullscreen不会让我回到原始视图。

term = blessings.Terminal()
term.enter_fullscreen

with term.location():
    print(term.move(0,(term.width/2)-7) + term.bold_green("Test Test Test"))
    print(term.move(5,(term.width/2)-7) + term.bold_red("Test Test Test"))

time.sleep(5)
term.clear
term.exit_fullscreen

This works except for clear and exit_fullscreen it seems. 这看起来除了clear和exit_fullscreen还有效。 There is no error message or anything, it just doesn't seem to do anything. 没有错误消息或任何东西,它似乎什么也没做。

Does anyone know how it works? 有谁知道它是如何工作的?

Edit: Neither 编辑:都没有

term.clear

nor 也不

term.clear()

seem to work... 似乎工作......

edit2: EDIT2:

I can pretty much do this and the result is the same as above. 我几乎可以这样做,结果与上面相同。 It does the coloring and placement but not clearing or anything else. 它进行着色和放置但不清除或其他任何东西。

term = blessings.Terminal()

with term.location():
    print(term.move(0,(term.width/2)-7) + term.bold_green("Test Test Test"))
    print(term.move(5,(term.width/2)-7) + term.bold_red("Test Test Test"))

Just as with all the other capabilities exposed by Blessings, you have to print them for them to have any effect. 正如Blessings所展示的所有其他功能一样,您必须print它们才能产生任何效果。 What's happening under the covers is that your terminal emulator is "listening" for certain sequences, and then it responds by taking actions such as switching in or out of fullscreen mode. 在幕后发生的事情是您的终端仿真器正在“监听”某些序列,然后它通过采取诸如切换到全屏模式的操作来响应。 So, in your case, saying print term.enter_fullscreen should do the trick. 所以,在你的情况下,说print term.enter_fullscreen应该可以解决问题。 Let me know if you have any more problems! 如果您还有其他问题,请告诉我!

As I read through your issue (facing the same one myself) I realized that I had forgotten that all the term.some_formatting() calls returned a value that you then had to print. 当我读完你的问题(我自己面对同一个问题)时,我意识到我忘记了所有的term.some_formatting()调用返回了一个你必须打印的值。 The clear function merely returns the appropriate escape sequences. clear函数仅返回适当的转义序列。

If you add: print(term.clear()) when you want it cleared it should work. 如果你想要它清除它时添加: print(term.clear())它应该工作。

Additionally, I had issues with ex_fullscreen, so I used the wrapper style call of fullscreen: 另外,我遇​​到了ex_fullscreen的问题,所以我使用了全屏的包装样式调用:

with term.fullscreen():
    a_function_or_some_code()

That should return you to your previous state upon exiting the code block. 这应该在退出代码块时返回到您之前的状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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