Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,38 @@
# OH24-Python

# Language Learning Game

This is a simple Translator Software built using Python and Tkinter. The application allows users to translate text from one language to another using the translate library.

## Features

User-friendly graphical interface.
Support for translation between multiple languages.

## Prerequisites

Before running the application, make sure you have the necessary dependencies installed:

Python 3
translate library
Tkinter library

Run this command: `pip install translate`

## How to Run

Clone the repository to your local machine.
Open a terminal and navigate to the project directory.
Run the following command:


Run: `python translator_software.py`

The Translator Software window should appear, allowing you to interact with the application.

## Usage

Select the source language from the first dropdown menu.
Select the target language from the second dropdown menu.
Enter the text you want to translate in the "Enter text" field.
Click the "Translate" button.
The translated text will appear in the "Output" field.
54 changes: 54 additions & 0 deletions translator_software.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
from tkinter import *
from translate import Translator

#Translator function
def translate():
translator= Translator(from_lang=lan1.get(),to_lang=lan2.get())
translation = translator.translate(var.get())
var1.set(translation)

#Tkinter root Window with title
root = Tk()
root.title("Translator")

#Creating a Frame and Grid to hold the Content
mainframe = Frame(root)
mainframe.grid(column=0,row=0, sticky=(N,W,E,S) )
mainframe.columnconfigure(0, weight = 1)
mainframe.rowconfigure(0, weight = 1)
mainframe.pack(pady = 100, padx = 100)

#variables for dropdown list
lan1 = StringVar(root)
lan2 = StringVar(root)

#choices to show in dropdown menu
choices = { 'English','Hindi','Gujarati','Spanish','German'}
#default selection for dropdownlists
lan1.set('English')
lan2.set('Hindi')

#creating dropdown and arranging in the grid
lan1menu = OptionMenu( mainframe, lan1, *choices)
Label(mainframe,text="Select a language").grid(row = 0, column = 1)
lan1menu.grid(row = 1, column =1)

lan2menu = OptionMenu( mainframe, lan2, *choices)
Label(mainframe,text="Select a language").grid(row = 0, column = 2)
lan2menu.grid(row = 1, column =2)

#Text Box to take user input
Label(mainframe, text = "Enter text").grid(row=2,column=0)
var = StringVar()
textbox = Entry(mainframe, textvariable=var).grid(row=2,column=1)

#textbox to show output
#label can also be used
Label(mainframe, text = "Output").grid(row=2,column=2)
var1 = StringVar()
textbox = Entry(mainframe, textvariable=var1).grid(row=2,column=3)

#creating a button to call Translator function
b=Button(mainframe,text='Translate',command=translate).grid(row=3,column=1,columnspan=3)

root.mainloop()