PyGame으로 이미지를 그리려하고 Adafruit에서이 코드를 복사했습니다. 이상하게도 Ctrl-C를 누르기 전에는 아무 것도 화면에 표시되지 않는 것 같습니다. 이때 이미지가 표시됩니다. 그런 다음 Ctrl-C를 다시 누를 때까지 이미지가 화면에 그대로 유지됩니다.키보드 인터럽트가 생길 때까지는 Python 프로그램이 응답하지 않습니다.
역 추적 (마지막으로 가장 최근 통화) : : 다음 다음과 같은 메시지가 얻을
time.sleep에,
파일 "RaspiDisplay.py", 라인 (60) (10)
KeyboardInterrupt
무슨 일 이니? 그건 그렇고, 나는 라즈베리 파이에 ssh를 통해 디스플레이를 0 (내 TV)로 설정하고 있습니다. 에 print 문을 넣으면 Ctrl-C를 누르기 전까지는 인쇄되지 않습니다.
import os
import pygame
import time
import random
class pyscope :
screen = None;
def __init__(self):
"Ininitializes a new pygame screen using the framebuffer"
# Based on "Python GUI in Linux frame buffer"
# http://www.karoltomala.com/blog/?p=679
disp_no = os.getenv("DISPLAY")
if disp_no:
print "I'm running under X display = {0}".format(disp_no)
# Check which frame buffer drivers are available
# Start with fbcon since directfb hangs with composite output
drivers = ['fbcon', 'directfb', 'svgalib']
found = False
for driver in drivers:
# Make sure that SDL_VIDEODRIVER is set
if not os.getenv('SDL_VIDEODRIVER'):
os.putenv('SDL_VIDEODRIVER', driver)
try:
pygame.display.init()
except pygame.error:
print 'Driver: {0} failed.'.format(driver)
continue
found = True
break
if not found:
raise Exception('No suitable video driver found!')
size = (pygame.display.Info().current_w, pygame.display.Info().current_h)
print "Framebuffer size: %d x %d" % (size[0], size[1])
self.screen = pygame.display.set_mode(size, pygame.FULLSCREEN)
# Clear the screen to start
self.screen.fill((0, 0, 0))
# Initialise font support
pygame.font.init()
# Render the screen
pygame.display.update()
def __del__(self):
"Destructor to make sure pygame shuts down, etc."
def test(self):
# Fill the screen with red (255, 0, 0)
red = (255, 0, 0)
self.screen.fill(red)
# Update the display
pygame.display.update()
# Create an instance of the PyScope class
scope = pyscope()
scope.test()
time.sleep(10)
strace로 프로그램을 실행하여 대기중인 내용을 확인하십시오. –
글쎄, 난 strace를을 실행하고 내 프로그램이에 갇히지 같다 : IOCTL (4, KDGKBENT는 0xbe90befc이) = 0 IOCTL (4, KDGKBENT는 0xbe90befc) = 0 IOCTL (4, KDGKBENT는 0xbe90befc) = 0 IOCTL (4 KDGKBENT, 0xbe90befc) = 0 IOCTL (4 KDGKBENT, 0xbe90befc) = 0 IOCTL (4 KDGKBENT가 0xbe90befc) = 0 IOCTL (4 KDGKBENT가 0xbe90befc) = 0 IOCTL (4 KDGKBENT, 0xbe90befc) = 0 IOCTL (4 KDGKBENT가 0xbe90befc) = 0 IOCTL (4, KDGKBENT가 0xbe90befc)은 = 0 IOCTL (4 KDGKBENT는 0xbe90befc) = 0 IOCTL (4 KDGKBENT는 0xbe90befc) = 0 –
왜 당신은'시간 잠 들어 (10)'하고 있니? 나는 그 문제가 어디에 있는지를 약 80 % 확신합니다. 전체 프로그램을 10 초 동안 기다리면 파이 게임 이벤트 루프가 10 초 동안 실행될 기회를 얻지 못하게됩니다. 이는 정확히보고있는 것입니다. – abarnert