Draw a circle in Pygame using Tkinter Draw a circle in Pygame using Tkinter tkinter tkinter

Draw a circle in Pygame using Tkinter


Been meaning to do this for a while, but I had time now, this is some basic code, the program makes a tkinter window and then embeds a pygame window in a frame, it then makes another frame and puts a button on that window that when pressed, calls a function that tells pygame to draw a circle on the pygame window.

import pygameimport Tkinter as tkfrom Tkinter import *import osroot = tk.Tk()embed = tk.Frame(root, width = 500, height = 500) #creates embed frame for pygame windowembed.grid(columnspan = (600), rowspan = 500) # Adds gridembed.pack(side = LEFT) #packs window to the leftbuttonwin = tk.Frame(root, width = 75, height = 500)buttonwin.pack(side = LEFT)os.environ['SDL_WINDOWID'] = str(embed.winfo_id())os.environ['SDL_VIDEODRIVER'] = 'windib'screen = pygame.display.set_mode((500,500))screen.fill(pygame.Color(255,255,255))pygame.display.init()pygame.display.update()def draw():    pygame.draw.circle(screen, (0,0,0), (250,250), 125)    pygame.display.update()button1 = Button(buttonwin,text = 'Draw',  command=draw)button1.pack(side=LEFT)root.update()while True:    pygame.display.update()    root.update()