DelphiPythonPython GUIWindows

Learn To Build A Python GUI For Scientific Computing With The NumPy Library In A Delphi Windows App


If you need to perform complex transformations or mathematical calculations with matrices or arrays, then Python’s Numpy library is exactly what you need. You can easily run this library and give it a nice GUI using Python4Delphi (P4D). Python4Delphi is a free tool that allows you to work with Python scripts and objects, even create new Python modules and types in the Windows GUI.

The NumPy library is a popular Python library used for scientific computing applications, and is an acronym for “Numerical Python”. NumPy is the fundamental package for array computing with Python.

NumPy’s operations are divided into three main categories: Fourier Transform and Shape Manipulation, Mathematical and Logical Operations, and Linear Algebra and Random Number Generation. To make it as fast as possible, NumPy is written in C and Python.

Besides its obvious scientific uses, NumPy can also be used as an efficient multi-dimensional container of generic data. Arbitrary data-types can be defined. This allows NumPy to seamlessly and speedily integrate with a wide variety of databases.

This post will guide you on how to run the NumPy library using Python for Delphi to display it 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.



1. Create a Matrix and Get Some Properties

This example shows how to create a 3-dimensional array and fill it with numbers from 0 to 29. Then, using the properties of this array, we can find out its shape, dimension, data type, number of elements:

Let’s see the output in our P4D VCL:



2. Basic Operations with Arrays

Let’s take a look at the simplest conversions you can perform on arrays. Using concatenate() function, you can combine the values of two arrays into one. With function sort() you can sort ascending the values in an array. Function reshape() allows you to change the dimension of the array:

The result:



3. Create an Array of All Zeros

We can use the zeros method to create an array of all zeros as shown below:

The result in Python GUI:


Congratulations, now you have learned how to run the NumPy library using Python for Delphi to display it in the Delphi Windows GUI app! These are only some basic examples of what Numpy library allows us to do. 

Check out the NumPy for numerical computing library for Python and use it in your projects: and

Check out Python4Delphi which easily allows you to build Python GUIs for Windows using Delphi:

Related posts
DelphiDelphiVCLPythonPython GUIWindows

What is DelphiVCL.Application.CreateHandle?

DelphiDelphiVCLPythonPython GUIWindows

Creating A New Application With DelphiVCL.Application.Create

DelphiDelphiVCLPythonPython GUIWindows

All You Need To Know About Application.DialogHandle

DelphiDelphiVCLPythonPython GUIWindows

What is the FieldAddress Property in DelphiVCL.Application?

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *