Merge pull request #1643 from kreegahbundolo/master

Made PyGame integration work on Linux by changing the SDL_VIDEODRIVER setting.
This commit is contained in:
MikeTheWatchGuy 2019-06-27 20:42:47 -04:00 committed by GitHub
commit 6a8032062d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -5,7 +5,9 @@ import os
"""
Demo of integrating PyGame with PySimpleGUI, the tkinter version
A similar technique may be possible with WxPython
Only works on windows from what I've read
To make it work on Linux, set SDL_VIDEODRIVER like
specified in http://www.pygame.org/docs/ref/display.html, in the
pygame.display.init() section.
"""
# --------------------- PySimpleGUI window layout and creation --------------------
layout = [[sg.T('Test of PySimpleGUI with PyGame')],
@ -18,7 +20,7 @@ graph = window.Element('_GRAPH_')
# -------------- Magic code to integrate PyGame with tkinter -------
embed = graph.TKCanvas
os.environ['SDL_WINDOWID'] = str(embed.winfo_id())
os.environ['SDL_VIDEODRIVER'] = 'windib'
os.environ['SDL_VIDEODRIVER'] = 'windib' # change this to 'x11' to make it work on Linux
# ----------------------------- PyGame Code -----------------------------
@ -36,4 +38,4 @@ while True:
pygame.draw.circle(screen, (0, 0, 0), (250, 250), 125)
pygame.display.update()
window.Close()
window.Close()