From b5d4c128a388dbc1aeb8a32d0b55c48886dcee4f Mon Sep 17 00:00:00 2001 From: PySimpleGUI Date: Fri, 8 Nov 2019 13:31:27 -0500 Subject: [PATCH] Initial Check in of new Matplotlib Demo --- DemoPrograms/Demo_Matplotlib_Two_Windows.py | 25 +++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 DemoPrograms/Demo_Matplotlib_Two_Windows.py diff --git a/DemoPrograms/Demo_Matplotlib_Two_Windows.py b/DemoPrograms/Demo_Matplotlib_Two_Windows.py new file mode 100644 index 00000000..799723e5 --- /dev/null +++ b/DemoPrograms/Demo_Matplotlib_Two_Windows.py @@ -0,0 +1,25 @@ +import PySimpleGUI as sg +import matplotlib.pyplot as plt + +""" + Simultaneous PySimpleGUI Window AND a Matplotlib Interactive Window + A number of people have requested the ability to run a normal PySimpleGUI window that + launches a MatplotLib window that is interactive with the usual Matplotlib controls. + It turns out to be a rather simple thing to do. The secret is to add parameter block=False to plt.show() +""" + + +layout = [[sg.Button('Plot'), sg.Cancel(), sg.Button('Popup')]] +main_window = sg.Window('Have some Matplotlib....', layout) + +while True: + event, values = main_window.Read() + if event in (None, 'Cancel'): + break + elif event == 'Plot': + history = [0.1, 0.2, 0.5, 0.7] + plt.plot(history) + plt.show(block=False) + elif event == 'Popup': + sg.popup('Yes, your application is still running') +main_window.close()