From f7db14f842d5b2bf91350f9ce253a8484a935d5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85ge=20Strand?= Date: Thu, 27 Jun 2019 09:13:40 +0200 Subject: [PATCH] Made it work on Linux by changing the SDL_VIDEODRIVER setting. --- DemoPrograms/Demo_PyGame_Integration.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/DemoPrograms/Demo_PyGame_Integration.py b/DemoPrograms/Demo_PyGame_Integration.py index dae260ff..0277be1e 100644 --- a/DemoPrograms/Demo_PyGame_Integration.py +++ b/DemoPrograms/Demo_PyGame_Integration.py @@ -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() \ No newline at end of file +window.Close()