using bits of code from another question, I embedded a pygame window in a tkinter window, I'm trying to make a tkbutton that draws a circle on the pygame window, been experimenting for a while and haven't turned any results so far. Any ideas would be great! Here's the code I have so far...
import Tkinter as tk
import os
import pygame as py
# R G B
red = (225, 0, 0)
green = (0, 255, 0)
w, h = 500, 200
p = False
def maketrue(p):
p = True
returnp
root = tk.Tk()
window = tk.Frame(root, width=w, height=h)
window.pack()
os.environ['SDL_WINDOWID'] = str(window.winfo_id())
root.update
py.display.init()
screen = py.display.set_mode((w, h))
screen.fill(py.Color(255, 0, 0))
drawbutton = tk.Button(root, text='Draw Circle', command = maketrue(p))
drawbutton.pack()
while True:
if p == True:
py.draw.circle(screen, red, (250, 50), 20)
py.display.update()
else:
pass
py.draw.circle(screen, green, (250, 100), 20)
root.update()
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…