Advertisement
XxDLCENERGYxX

tkinter and pygame

Dec 4th, 2016
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. import tkinter, pygame, os
  2.  
  3. w,h = 500,200
  4.  
  5. root = tkinter.Tk()
  6. embed = tkinter.Frame(root,width=w,height=h)
  7. embed.pack()
  8.  
  9. os.environ['SDL_WINDOWID'] = str(embed.winfo_id()) # this makes it work
  10. screen = pygame.display.set_mode((w,h))
  11. fpsclock = pygame.time.Clock()
  12.  
  13. x = 0
  14. radius = 30
  15. mod = w+radius*2
  16.  
  17. while True:
  18.     try: root.update()
  19.     except: break
  20.  
  21.     ticks = fpsclock.tick()
  22.     if ticks>100: continue
  23.     dt = ticks/1000
  24.  
  25.     screen.fill((0,0,0))
  26.     pygame.draw.circle(screen,(255,255,255),(int(x)-radius,100),radius)
  27.     pygame.display.flip()
  28.  
  29.     x = (x+dt*100)%mod
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement