[python] pygame 윈도우 샘플

pygame으로 윈도우를 띄우는 샘플코드입니다.


import pygame

# 윈도우 타이틀
pygame.display.set_caption('Tutorial 1')

# 배경화면 색상
background_color = (255,255,255)

# 윈도우 사이즈
(width, height) = (300, 200)
screen = pygame.display.set_mode((width, height))
screen.fill(background_color)

# 윈도우 표기
pygame.display.flip()

running = True
while running:
    for event in pygame.event.get():
        # 닫기 버튼 감지
        if event.type == pygame.QUIT:
            running = False



아래는 실행결과입니다.



끝.

댓글

이 블로그의 인기 게시물

[PLC] PLC 아날로그 입출력 기본

NPN, PNP 트랜지스터 차이점

전력(kW) 계산하기 (직류, 교류 단상, 교류 삼상)

커패시터에 저장된 에너지 계산

3선 결선식 센서의 타입 PNP, NPN

제너 다이오드에 저항을 연결하는 이유

3상 모터 전력에서 전류 계산하기 (How to Convert Three-Phase Power to Amps)

[아두이노] 가변저항(Potential Divider)과 전압분배(Voltage Divider)

[공압밸브] 5포트 2웨이 & 4포트 2웨이, 단동 VS 복동 차이점

공압 속도 제어: 미터인 vs 미터아웃