Build a desktop calculator app with Axino and Electron in one minute.

Image for post
Image for post
Desktop calculator app

Here is the recipe:

Step 1 Download the tools:

Tool 1: npm

Npm is required to install Axino, Typescript and Parcel:

npm is installed as explained on the npm homepage: https://www.npmjs.com/get-npm

Be sure to download the version of npm which is compatible with your platform: Mac, Windows or Linux.

Tool 2: Typescript

Once npm is installed on your system, all the other tools can be installed via npm:

Typescript is installed by entering the following npm command in a terminal:

npm install -g typescript

Tool 3: Parcel

Parcel is installed in the same way by entering:

npm install -g parcel-bundler

Step 2 Create a directory for your app:

mkdir myapp (Linux and Mac)

or use your favorite “file manager” to create a dedicated directory.

Step 3 : initialize your app:

In the directory in question, run the command:

npm init -y
npm i Axino

in order to have a local “node_modules” directory installed by npm (which in turn will contain the Axino directory) , like this:

myapp
¦-- node_modules
¦-- axino

Step 4 : Go to the Axino examples subdirectory:

cd axino/examples-electron-calculator/

Step 5: Initialize the calculator example:

In axino/examples-electron-calculator/ run the command:

npm install

then:

npm run build

then:

npm run start

That’s it, you should now see your app:

Image for post
Image for post

NB: This app uses the function: evaluate(), which is a quick and dirty method to evaluate an algebraic expression. This is just a hack to emulate the functioning of a calculator. Since this evaluate() function is not deemed secure, a warning is displayed on the debugging tab on the right-hand part of the app. This debugging pane can be closed. When it is closed the app looks like the one displayed in the header of this article.

Image for post
Image for post

The code of the app is contained in the file:

examples-electron-calculator/app.ts

Feel free to experiment with it!

Happy programming! :-)

Author, scientist (Physics PhD), philosophy, Sci-Fi, thrillers, humor, blues and Irish music, green energy, origins of consciousness.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store