DelphiPythonPython GUIWindows

Learn To Build A Python GUI For Interactive Data Visualizations Using Bokeh Library In A Delphi Windows App

photo of woman holding a gray laptop in front of systems

With the growing demand for Data Science and Analytics skill sets, drawing graphics programmatically is a very popular task these days. Especially the need for real-time and interactive graphics. You can easily create a GUI app for interactive plots by combining the power of the Bokeh library with Python4Delphi (P4D). P4D is a free set of powerful tools that allows you to work with Python scripts, modules, and types in Delphi and easily create Windows GUI with it.

Bokeh is an interactive visualization library for modern web browsers. It provides elegant, concise construction of versatile graphics, and affords high-performance interactivity over large or streaming datasets. Bokeh can help anyone who would like to quickly and easily make interactive plots, dashboards, and data applications.

This post will guide you on how to run the Bokeh 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.

0 rundemo1 6813476

At a glance, Bokeh  provides us with:

  • Flexible

Bokeh makes it simple to create common plots but also can handle custom or specialized use-cases.

  • Interactive

Tools and widgets let you and your audience probe “what if” scenarios or drill-down into the details of your data.

  • Shareable

Plots, dashboards, and apps can be published on web pages or Jupyter notebooks.

  • Productive

Work in Python close to all the PyData tools you are already familiar with.

  • Powerful

You can always add custom JavaScript to support advanced or specialized cases.

  • Open Source

Everything, including the Bokeh server, is BSD licensed and available on GitHub.

Let’s try an interactive map plot from Bokeh example gallery.

 

1. Installing Sample Data

Bokeh can download and install a collection of sample data. This includes a variety of freely available data tables and databases that you can use with Bokeh. This sample data is rather large, so it is not included in Bokeh’s installation packages by default.

In this tutorial, we will use the Texas unemployment dataset in 2009 as our sample data. Use the following code to download all available sample datasets:

The result in Python GUI:

1downloadsampledata 2120255

 

2. Demo: Plotting the Unemployment Rate in Texas

Run the following code in your Python4Delphi VCL Demo1, for plotting the unemployment rate in Texas. We use the demo from Bokeh documentation:

When you execute the script above, your default browser will automatically open to display your interactive plot.

2texasunemployment 3658878

Move your cursor to any County, and you can see the unemployment rate and the coordinate for that County. Bokeh also provides these tools in your plot: Pan, Wheel Zoom, Reset, Hover, Save or Download plot.

 

Congratulations, now you have learned how to run the Bokeh library using Python for Delphi to display it in the Delphi Windows GUI app! Now you can solve various real-world problems using enterprise-grade interactive plots created by the Bokeh library and Python4Delphi. The only limit is your imagination.

Check out the Bokeh data visualization library for Python and use it in your projects: https://pypi.org/project/bokeh/  and

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

Related posts
CodeIDELearn PythonPythonPython GUITkinter

How To Make More Than 20 ChatGPT Prompts Work With Python GUI Builders And NumPy Library?

CodeIDEProjectsPythonWindows

Unlock the Power of Python for Deep Learning with Generative Adversarial Networks (GANs) - The Engine behind DALL-E

CodeIDELearn PythonPythonPython GUITkinter

How To Make More Than 20 ChatGPT Prompts Work With Python GUI Builders And Matplotlib Library?

CodeIDELearn PythonPythonPython GUITkinter

How To Make More Than 20 ChatGPT Prompts Work With Python GUI Builders And Pillow Library?

Leave a Reply

Your email address will not be published. Required fields are marked *