A simple python GUI calculator using TKInter

Hello everybody, Welcome back to programminginpython.com! Now am going to show you how to make a simple python GUI application, basically the app is a simple calculator which adds two numbers. I used TKInter which is a standard GUI package for python. In the previous post I covered about the basic introduction to GUI programming in python, here I will use those and also extend some other things to build this simple app.

Program on Github

Below are the screenshots, how our basic app looks like,

Calculator GUI - programminginpython.com
Calculator GUI – programminginpython.com
Calculator GUI - programminginpython.com
Calculator GUI – programminginpython.com

 

Here I used, grid layout for designing the layout, in the previous post, I told about pack() which sets the widgets automatically based on available space in the window, but here we can set the widgets where we want to place.

Firstly import and initialize TKInter,

I also set the size of the app and its title,

I also added some labels and input fields to read the entered numbers,

Then I add a button, when clicked, calculates the result and displays it in the label labelResult I initialized above.

Program on Github

So when the button is clicked, a function is called which calculates the sum of both the numbers.

The command parameter to Button function calls the call_resultfunction, which does the simple logic.

The call_result function.

Program on Github

Feel free to look at my previous posts on python GUI programming.

Program

 

3 Comments

  1. Pingback: educational websites for students

  2. Pingback: school education

  3. Pingback: online education programs

Leave a Reply