Site icon Python GUI

Learn to Automatically Generating A CLIs Using Python’s Fire Library In A Delphi Windows App

pexels tima miroshnichenko 5380590

Are you looking for powerful tools to automatically generate command-line interfaces to make your life easier, and build a nice GUI for them? You can build it easily by combining Fire and Python4Delphi library, inside Delphi and C++Builder.

Python Fire is a library for automatically generating command-line interfaces (CLIs) with a single line of code.

It will turn any Python module, class, object, function, etc. (any Python component will work!) into a CLI. It’s called Fire because when you call Fire(), it fires off your command.

Python’s Fire library will enable us to:

Hands-On

This post will guide you on how to automatically generate your own CLI using the Fire library and create it using Python for Delphi in the Delphi Windows GUI app.First, open and run our Python GUI using project Demo1 from Python4Delphi with RAD Studio. Then insert the script into the lower Memo, click the Execute button, and get the result in the upper Memo. You can find the Demo1 source on GitHub. The behind the scene details of how Delphi manages to run your Python code in this amazing Python GUI can be found at this link.

Let’s create a CLI for a simple “Hello World!”:

[crayon-662a77c68956d926661387/]

And run it in our Python GUI:

Save the script above as helloFire1.py, and then let’s test our CLI for printing “Hello World!” using these commands:

[crayon-662a77c689589754686268/]

 

Congratulations, now you have learned how to automatically generate your own CLI using the Fire library and create it using Python for Delphi in the Delphi Windows GUI app!

Check out the Fire library for Python and use it in your projects: https://pypi.org/project/fire/ and

Check out Python4Delphi which easily allows you to build Python GUIs for Windows using Delphi: https://github.com/pyscripter/python4delphi

Check out DelphiVCL which easily allows you to build GUIs for Windows using Python!

Exit mobile version