
This is the first post of a series of articles about Python 3. Python 3 support has been added in GeeXLab 0.26.0.0 and has been improved in GeeXLab 0.27.0.0, especially in the latest release 0.27.2.
On the Linux version, the Python 3 plugin is linked against Python 3.6 shared object (Python 3.6 is standard version on Linux Mint 19.1). On Windows, Python is not available in a standard installation. GeeXLab is shipped with Python 3.7.2, so you don’t need to install Python. But if you already have Python 3.7 installed on your system with lot of particular modules, you can tell GeeXLab to use this new Python home. Just edit the start_set_python_home.bat in GeeXLab folder and change the /python3_home.
For this first article, let’s start with simple but nonetheless important topic: the reading of system information. Python comes with several modules for retrieving system information: sys, platform and os. We’ll see how to display the current date/time as well.
To test this Python 3 demo, you need GeeXLab 0.27.2+. Download the demo, unzip the archive where you want and drag and drop the python3-demopack/py3-01-system-info/main.xml into GeeXLab.
Here is what I get on Linux Mint 19.1 (Python 3.6.7):

And on Windows 10 (Python 3.7.2):

All interesting things can be found in the frame.py file. By default live-coding is enabled in this demo, so you can edit the frame.py while GeeXLab is running and you will see your changes instantly.
For this demo, the required imports are the following:
import sys
import platform
import sysconfig
import os
import time
from time import gmtime, strftime
import datetime
Date and time: time and datetime modules
The elapsed time is displayed with:
ts = time.time()
gh_imgui.text("%.1f sec" % ts)
The date and time is displayed with:
st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
gh_imgui.text(st)
and with :
current_date = strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())
gh_imgui.text(current_date)
sys module
The information displayed by the sys module:
gh_imgui.text_rgba("sys.executable", color1[0], color1[1], color1[2], color1[3])
if (sys.executable == ""):
gh_imgui.text("_EMPTY_")
else:
gh_imgui.text(str(sys.executable))
gh_imgui.text_rgba("sys.float_info", color1[0], color1[1], color1[2], color1[3])
gh_imgui.text_wrapped(str(sys.float_info))
gh_imgui.text_rgba("sys.hexversion", color1[0], color1[1], color1[2], color1[3])
gh_imgui.text(str(sys.hexversion))
gh_imgui.text_rgba("sys.version", color1[0], color1[1], color1[2], color1[3])
gh_imgui.text(sys.version)
gh_imgui.text_rgba("sys.api_version", color1[0], color1[1], color1[2], color1[3])
gh_imgui.text(str(sys.api_version))
gh_imgui.text_rgba("sys.version_info", color1[0], color1[1], color1[2], color1[3])
gh_imgui.text(str(sys.version_info))
gh_imgui.text_rgba("sys.platform", color1[0], color1[1], color1[2], color1[3])
gh_imgui.text(sys.platform)
color1 is a tuple:
color1 = (0.2, 0.6, 1.0, 1.0)
platform module
The information displayed by the platform module:
gh_imgui.text_rgba("platform.architecture()", color1[0], color1[1], color1[2], color1[3])
gh_imgui.text(str(platform.architecture()))
gh_imgui.text_rgba("platform.processor()", color1[0], color1[1], color1[2], color1[3])
gh_imgui.text(str(platform.processor()))
gh_imgui.text_rgba("platform.system()", color1[0], color1[1], color1[2], color1[3])
gh_imgui.text(str(platform.system()))
gh_imgui.text_rgba("platform.uname()", color1[0], color1[1], color1[2], color1[3])
gh_imgui.text_wrapped(str(platform.uname()))
sysconfig module
The information displayed by the sysconfig module:
gh_imgui.text_rgba("sysconfig.get_python_version()", color1[0], color1[1], color1[2], color1[3])
gh_imgui.text(str(sysconfig.get_python_version()))
gh_imgui.text_rgba("sysconfig.get_path_names()", color1[0], color1[1], color1[2], color1[3])
gh_imgui.text(str(sysconfig.get_path_names()))
gh_imgui.text_rgba("sysconfig.get_path('stdlib')", color1[0], color1[1], color1[2], color1[3])
gh_imgui.text(str(sysconfig.get_path('stdlib')))
os module
The os seems to have a bug on Linux Mint 19.1 with the os.getlogin() function. The Python interpreter outputs the following error:
Error line: 153 - Error object:- Error data: OSError(25, 'Inappropriate ioctl for device')
The same function works perfectly on Windows. So I used the sys.platform info to test the platform:
if (sys.platform == "win32"):
gh_imgui.text_rgba("os.getlogin()", color1[0], color1[1], color1[2], color1[3])
gh_imgui.text(str(os.getlogin()))
gh_imgui.text_rgba("os.getpid()", color1[0], color1[1], color1[2], color1[3])
gh_imgui.text(str(os.getpid()))
gh_imgui.text_rgba("os.cpu_count()", color1[0], color1[1], color1[2], color1[3])
gh_imgui.text(str(os.cpu_count()))