pygame帧渲染到tkinter窗口示例程序

"""
   pygame帧渲染到tkinter窗口示例程序.py
"""
import os
import pygame
from tkinter import *

root =  Tk()
root.title("pygame帧渲染到tkinter窗口示例程序")

# 创建左边框架,用于渲染pygame帧
left_frame =  Frame(root, width = 500, height = 500) 
left_frame.pack(side = LEFT) # 放于左边对齐

# 创建右边框架,用来放按钮
right_frame =  Frame(root, width = 75, height = 500)
right_frame.pack(side = LEFT)

# 指定渲染的窗口的id号
os.environ['SDL_WINDOWID'] = str(left_frame.winfo_id())
# os.environ['SDL_VIDEODRIVER'] = 'windib'
screen = pygame.display.set_mode((500,500))
screen.fill(pygame.Color(205,55,255))

def draw_circle():
     """ 画圆圈函数 """
     pygame.draw.circle(screen, (0,255,0), (250,250), 62)
     pygame.display.update()
    

You must log in to read the rest of this article. Please log in or register as a user.