0
import pygame

from tkinter import *
import tkinter as tk
root = tk.Tk()

embed = tk.Frame(root, width = 660, height = 600) #creates embed frame for pygame window
embed.grid(columnspan = (700), rowspan = 600) # Adds grid
embed.pack(side = LEFT)
screen = pygame.display.set_mode((660,500))
screen.fill(pygame.Color(255,255,255))
pygame.display.init()
pygame.display.update()
pygame.display.set_caption("Pong Game")

I am trying to show the pygame window in a tkinter frame to place buttons for example. The code provided is similar to Embedding a Pygame window into a Tkinter or WxPython frame but it is not showing any frame in the background.

  • First you don't set up environment variables mentioned in the example link. Second the example does not work any more for pygame 2.x. – acw1668 Feb 14 '22 at 02:50
  • Please accept that there is no way to do what you want right now. See [Using 'SDL_WINDOWID' does not embed pygame display correctly into another application #1574](https://github.com/pygame/pygame/issues/1574) – Rabbid76 Feb 14 '22 at 05:55

0 Answers0