
- Python 3 Basic Tutorial
- Python 3 - Home
- What is New in Python 3
- Python 3 - Overview
- Python 3 - Environment Setup
- Python 3 - Basic Syntax
- Python 3 - Variable Types
- Python 3 - Basic Operators
- Python 3 - Decision Making
- Python 3 - Loops
- Python 3 - Numbers
- Python 3 - Strings
- Python 3 - Lists
- Python 3 - Tuples
- Python 3 - Dictionary
- Python 3 - Date & Time
- Python 3 - Functions
- Python 3 - Modules
- Python 3 - Files I/O
- Python 3 - Exceptions
Ratio Calculator GUI using Tkinter
In this article, we will see how to create a functional application that calculates the ratio. In order to make it fully functional, we will use SpinBox method that generally creates an ideal spinner for a value. This value can be modified using the spinner widget in the frame. Thus, a SpinBox object takes values in the range from minimum to maximum.
First, we will create a tkinter frame inside which we will define some widgets.
Example
from tkinter import * win = Tk() win.title("Ratio Calculator") win.geometry("600x500") win.resizable(0,0) #Create text Label for Ratio Calculator label= Label(win, text="Ratio Calculator", font=('Times New Roman', 25)) #Define the function to calculate the value def ratio_cal(): a1=int(a.get()) b1= int(b.get()) c1= int(c.get()) val= (b1*c1)/a1 x_val.config(text=val) #Add another frame frame= Frame(win) frame.pack() #Create Spin Boxes for A B and C a= Spinbox(frame, from_=0, to= 100000, font=('Times New Roman', 14), width=10) a.pack(side=LEFT,padx=10, pady=10) b= Spinbox(frame,from_=0, to=100000, font=('Times New Roman', 14), width=10) b.pack(side=LEFT, padx= 10, pady=10) c= Spinbox(frame, from_=0, to=100000, font=('Times New Roman', 14), width= 10) c.pack(side= LEFT, padx=10, pady=10) x_val= Label(frame, text="",font=('Times New Roman', 18)) x_val.pack(side=LEFT) #Create a Button to calculate the result Button(win, text= "Calculate",command=ratio_cal, borderwidth=3, fg="white", bg="black", width=15).pack(pady=20) win.mainloop()
Output
Running the above code will create a GUI-based Ratio Calculator.
- Related Articles
- Simple GUI calculator using Tkinter in Python
- How to build a simple GUI calculator using tkinter in Python
- Average Speed Calculator using Tkinter
- Creating a tkinter GUI layout using frames and grid
- How do I create an automatically updating GUI using Tkinter?
- How to create an impressive GUI in Python using Tkinter?
- How do I create an automatically updating GUI using Tkinter in Python?
- How to create a directly-executable cross-platform GUI app using Python(Tkinter)?
- How to use the "native" GUI look with Tkinter?
- Basic calculator program using Java
- Basic calculator program using Python
- Basic calculator program using C#
- Basic calculator program using Python program
- Prefix calculator using stack in JavaScript
- Automating SAP Transactions/actions using SAP GUI

Advertisements