From 7e4af56bdfc15430145db905f6365ce22f92ba56 Mon Sep 17 00:00:00 2001 From: PySimpleGUI Date: Thu, 27 Aug 2020 18:16:11 -0400 Subject: [PATCH] Demo of "PyCharm Me" Button --- DemoPrograms/Demo_PyCharm_Self_Edit.py | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 DemoPrograms/Demo_PyCharm_Self_Edit.py diff --git a/DemoPrograms/Demo_PyCharm_Self_Edit.py b/DemoPrograms/Demo_PyCharm_Self_Edit.py new file mode 100644 index 00000000..af8601b6 --- /dev/null +++ b/DemoPrograms/Demo_PyCharm_Self_Edit.py @@ -0,0 +1,30 @@ +import PySimpleGUI as sg +import subprocess + +""" + Demo PyCharm Launch - Edit this file button + + Quick demo to show you how to add a button to your code that when pressed will open the file + in PyCharm for editing. + + Note that this is a Windows version. You'll need a slightly different path for Linux. + + Copyright 2020 PySimpleGUI.org +""" + +# Change this variable to match the location of your PyCharm folder. It should already have the batch file. +PYCHARM = r"C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.1\bin\pycharm.bat" + +layout = [ [sg.Text('Edit Window Using PyCharm')], + [sg.Button('PyCharm Me'), sg.Button('Exit')] ] + +window = sg.Window('PyCharm Launch Demo', layout) + +while True: # Event Loop + event, values = window.read() + if event == sg.WIN_CLOSED or event == 'Exit': + break + if event == 'PyCharm Me': + subprocess.Popen([PYCHARM, __file__], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + +window.close()