English 中文(简体)
PySimpleGUI - Debugger
  • 时间:2025-02-05

PySimpleGUI - Debugger


Previous Page Next Page  

In addition to the built-in debugger that most IDEs such as PyCharm or VS Code have, PySimpleGUI offers its own debugger. This debugger provides you the abipty to "see" and interact with your code, while it is running.

To use the debugger service effectively, the window should be red asynchronously, i.e., you should provide a timeout to the read() function.

The debugger window is invoked by calpng show_debugger_window() function anywhere inside the program as shown below −


import PySimpleGUI as sg
sg.show_debugger_window(location=(10,10))
window = sg.Window( Debugger Demo ,
   [[sg.Text( Debugger ),
   sg.Input( Input here ),
   sg.Button( Push Me )]]
)
while True:
   event, values = window.read(timeout=500)
   if event == sg.TIMEOUT_KEY:
      continue
   if event == sg.WIN_CLOSED:
      break
   print(event, values)
window.close()

The PySimpleGUI debugger window appears at the specified screen location.

GUI Debugger

The window shows two tabs Variables and REPL. Cpck on the Variables tab. A pst of variables to auto-watch is shown Check the ones that you want to watch during the execution of the program.

GUI Debugger All Locals

The second tab about REPL gives a Python interactive console to be executed around your program’s environment so that you can inspect the values of desired variables in the code.

PysimpleGUI Debugger Advertisements