<![CDATA[ED LEIJNSE - Python]]>Mon, 24 Apr 2023 03:27:54 +0200Weebly<![CDATA[TI-84 Python edition - hybrid programming]]>Tue, 20 Jul 2021 16:00:19 GMThttp://wsb.leijnse.info/python/ti-84-python-edition-hybrid-programmingThe Texas Instruments TI-84 Plus CE-T calculator has a special edition called "Python Edition"
It's easy to develop Python programs for this system. 
I'm developping like this:
I develop the programs like normal python programs on a PC with an editor (in my case PyCharm and Notepad++).
To be able to test the program on a PC I've made the following design.
1. conditional support for imports from TI libraries, like this:
    from ti_system import *
except Exception as e:
     print ("no module ti_system")
2. read and write data wrapped in functions with a hybrid implementation
For reading data TI uses recall_list
For writing data TI uses store_list
On a "normal" system without the ti_system library this will not work.
So, I made wrapper functions with exception handling, e.g.
def saveeuro(ieuro):
  except NameError as e:

See github for the sourcecode:

<![CDATA[Python GUI tools]]>Wed, 17 Mar 2021 12:29:23 GMThttp://wsb.leijnse.info/python/python-gui-toolsTools

Most common tools: PyGuBU, Page, Gooey and PySimpleGui. PySimpleGui is not a design tool but is rather understandable and comes with a lot of samples. The other tools where very hard to install and didn't work properly on my Mac system.


<![CDATA[How to deploy PY script on a Mac]]>Tue, 16 Mar 2021 17:20:58 GMThttp://wsb.leijnse.info/python/how-to-deploy-py-script-with-on-a-macIf you've already installed "pyinstaller" (with pip install pyinstaller) you can run following command:
sudo pyinstaller YourPythonScript.py -n YourPythonScriptName --clean  --onefile
What happens: a Unix executable "YourPythonScriptName" will be created in the /dist directory.
It's just ONE FILE, no worries about security issues anymore.

Here is the complete article:

Mr. NetTek explains: how to deploy a Python script with pyinstaller on a mac

NOTE: THIS ARTICLE IS WRITTEN BY MrNetTek, click on the link above to see the original text.
Mac – pyinstaller – Create .APP FilePosted onMarch 15, 2019AuthorMrNetTek

PyInstaller reads a Python script written by you. It analyzes your code to discover every other module and library your script needs in order to execute. Then it collects copies of all those files – including the active Python interpreter! – and puts them with your script in a single folder, or optionally in a single executable file, and an APP.
pip3 install pyinstaller

1sudo pyinstaller Notify.py -n Notify --windowed --noconfirm --clean

Other packages/dependencies you may need before compiling:
xcode-select –install
ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
brew install python3
brew link python
brew postinstall python
pip3 install -U py2app

pip3 install Pillow
brew install tcl-tk
pip3 install virtualenv
brew install pyside
pip3 install sip
brew install cartr/qt4/pyqt@4
brew install PyQt5
brew install opencv@2
brew install git

pip3 install opencv-python
pip install python-resize-image

If you specify only --onefile under Mac OS X, the output in dist is a UNIX executable myscript. It can be executed from a Terminal command line. Standard input and output work as normal through the Terminal window.
If you also specify --windowed, the dist folder contains two outputs: the UNIX executable myscript and also an OS X application named myscript.app.
As you probably know, an application is a special type of folder. The one built by PyInstaller contains a folder always named Contents. It contains:
  • A folder Frameworks which is empty.
  • A folder MacOS that contains a copy of the same myscript UNIX executable.
  • A folder Resources that contains an icon file.
  • A file Info.plist that describes the app.

PyInstaller builds minimal versions of these elements.
Use the icon= argument to specify a custom icon for the application. (If you do not specify an icon file, PyInstaller supplies a file icon-windowed.icns with the PyInstaller logo.)

<![CDATA[How to make a collection of class instances]]>Mon, 15 Mar 2021 20:55:23 GMThttp://wsb.leijnse.info/python/how-to-make-a-collection-of-class-instancesDesign the class, decide which attributes you need
Make a collection and fill the collection with instances of MyCustomer. Read the collection and print it.
<![CDATA[Quick start with Python]]>Mon, 15 Mar 2021 15:35:48 GMThttp://wsb.leijnse.info/python/quick-start-with-pythonPython is a functional programming language, positional bound.
It's syntax is easy to understand. The ":" sign plays a very significant role.
You see it in functions:
def open_directory(mydir, mytitle):
as well as in "if" statements:
if not dirpath: return
It is allowed to store all code in one file, you can mix classes with functions.
And it's even allowed to use functions within functions! Very helpful.

Of course you need an editor. I'm very happy with Jetbrains PyCharm, there is even a free public version

As a sample I've added some code here to start with a GUI:
TIP: add helpfull links to the top of your python file: