ssh - 来自 ssh 会话的 pygame:如何在附加屏幕上显示?
问题描述
我想在 raspi 上使用 pygame 在连接到 raspi 的 hdmi 端口的屏幕上显示图片。我想通过 ssh 连接来做到这一点。
作为第一个测试,我尝试了测试可用驱动程序的非常基本(和经典)的脚本:
import os
import pygame
disp_no = os.getenv('DISPLAY')
print("I'm running under {}".format(disp_no))
drivers = ['directfb', 'fbcon', 'svgalib']
found = False
for driver in drivers:
if not os.getenv('SDL_VIDEODRIVER'):
os.putenv('SDL_VIDEODRIVER', driver)
os.environ["SDL_FBDEV"] = "/dev/fb0"
try:
pygame.display.init()
print('OK with',driver)
except pygame.error:
print('Driver: {0} failed.'.format(driver))
continue
found = True
break
if not found:
raise Exception('No suitable video driver found!')
这是我的测试结果:
- 来自 ssh 会话:找不到合适的视频驱动程序
- 以 root 身份从 ssh 会话:使用 directfb 可以
- 从 tty 控制台(使用连接到 raspi 的键盘):使用 directfb 可以
我的问题是:为什么情况 1 会导致失败。我想念什么,我该怎么办?
请注意 /dev/fb0 和所有 /dev/tty 的权限??设置为我可以在没有 root 的情况下读/写。另请注意,我没有运行 X 服务器。
解决方案
推荐阅读
- php - PHP视频上传不起作用
- c# - 如何在 ASP 模板中有条件地生成 html
- swift - Swift - 在 NSTableView 中使用复选框获取行索引
- mysql - 我的查询缺少零的行
- django - Django 使用 kwargs 将值从视图传递到非模型表单
- django - HTTP 500 错误 - 目标 WSGI 脚本无法作为 Python 模块加载
- visualization - 有没有一种简单的方法可以在 Socrata 上映射属性?
- c - 如何在 C 中浏览任意长度的字符串数组?
- fotorama - Fotorama如何嵌入iframe?
- java - 当此视图位于另一个布局中的布局中时,如何获取窗口中的视图位置?