Site icon Embarcadero RAD Studio, Delphi, & C++Builder Blogs

Quickly Log Python Script Output To The Delphi Debug Log In Your Windows Apps

Sometimes developers need to log the output messages in Delphi for debugging purposes. You might aware this can be achieved by the windows API OutputDebugStringA . How about direct your python output messages to the Delphi Events Log Window? Yes, Python4Delphi has a flexible component PythonInputOutput to redirect your python output to the Delphi Events Log window with less code. You can also use Python4Delphi with C++Builder.

Python4Delphi Demo23 Sample App shows how to create a Python script in Delphi Application which demonstrates creating thread and output the result in the Delphi Event log window. You can find the Demo23 source on GitHub.

Prerequisites: Download and install the latest Python for your platform. Follow the Python4Delphi installation instructions mentioned here. Alternatively, you can check out this video Getting started with Python4Delphi.

Components used in Python4Delphi Demo23 App:

You can find the Python4Delphi Demo23 sample project from the extracted GitHub repository ..Python4DelphiDemosDemo23.dproj. Open this project in RAD Studio 10.4.1 and run the application.

Implementation Details:

[crayon-673fec268a6ac216294504/]

The script below is executed which will opens a window console, create threads put in a queue and execute one after other.

[crayon-673fec268a6b5270258451/]
[crayon-673fec268a6b7709702983/]
<strong>Python4Delphi Demo23<strong>

You can customize your Events Debug Output messages background and foreground colors easily to differentiate your output messages with Delphi IDE. Right-click in the Events Tab -> Properties->Event Log->Colors -> Output Debug String-> Select Foreground and Background.

Exit mobile version