How to display text on the screen without a window using Python

后端 未结 2 1401
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-02 10:08

The Problem:

I need to write text directly to the screen without a window. The text needs to appear above all other windows and full-screen applications and should

2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-02 10:47

    I had a similar need and discovered that the pygame library did a REALLY good job for what I was seeking. I was able to generate very large text that would update very fast and without flicker. See this topic below (first code 'solution' is it):

    Simple way to display text on screen in Python?

    I sped it up and it is fast. Also made the font much larger and that didn't impact speed much at all. All of that running on a little Orange Pi Lite board (< $20). You can launch it from the command line w/o GUI (or from a windowed desktop) and in either case it is full-screen and doesn't appear as a "windowed" app.

    My assumption, as I'm new to Python and Pygame, is that you could load an image file as the background and then put text atop of that.

    Oh, and I tried the same using the Tkinter example and it was slower, flickered, and the font just didn't look "right". Pygame was clearly the winner. It's designed to blit things to the screen without "tearing" as games need to not flicker when images update. I was surprised that it wasn't dependent on OpenGL because it was fast. I don't think OpenGL is supported on the Orange Pi (can't figure out a clear answer on that). So for 2D stuff, wow, pygame is impressive.!

提交回复
热议问题