5

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.

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. 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:

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"))
Zaheer Ahmed
  • 28,160
  • 11
  • 74
  • 110
Jrc
  • 367
  • 2
  • 4
  • 14

2 Answers2

6

Just as with all the other capabilities exposed by Blessings, you have to print them for them to have any effect. 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. Let me know if you have any more problems!

Erik Rose
  • 141
  • 2
  • 3
1

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. The clear function merely returns the appropriate escape sequences.

If you add: print(term.clear()) when you want it cleared it should work.

Additionally, I had issues with ex_fullscreen, so I used the wrapper style call of fullscreen:

with term.fullscreen():
    a_function_or_some_code()

That should return you to your previous state upon exiting the code block.

freshvolk
  • 81
  • 3