Made it work on Linux by changing the SDL_VIDEODRIVER setting.

This commit is contained in:
Åge Strand 2019-06-27 09:13:40 +02:00
parent a1c29f6b48
commit f7db14f842
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 Demo of integrating PyGame with PySimpleGUI, the tkinter version
A similar technique may be possible with WxPython 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 -------------------- # --------------------- PySimpleGUI window layout and creation --------------------
layout = [[sg.T('Test of PySimpleGUI with PyGame')], layout = [[sg.T('Test of PySimpleGUI with PyGame')],
@ -18,7 +20,7 @@ graph = window.Element('_GRAPH_')
# -------------- Magic code to integrate PyGame with tkinter ------- # -------------- Magic code to integrate PyGame with tkinter -------
embed = graph.TKCanvas embed = graph.TKCanvas
os.environ['SDL_WINDOWID'] = str(embed.winfo_id()) 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 ----------------------------- # ----------------------------- PyGame Code -----------------------------