Question

In: Computer Science

Using Python Look at the following list of Spanish words and their meanings. Spanish English uno...

Using Python

Look at the following list of Spanish words and their meanings.

Spanish English

uno one

dos two

tres three

Write a GUI program that translates the Spanish words to English. The window should have three buttons, one for each Spanish word. When the user clicks a button, the program displays the English translation in a label.

Solutions

Expert Solution

Python code for the given problem statement is as follows:

(Appropriate Comments are given as and when necessary for your easy understanding)

from tkinter import *
def clear_all() :  
    translate_field.delete(0, END) 
    # set focus on the translate_field entry box   
    translate_field.focus_set()  

def translate1():  
    translate_field.insert(10,"One") 
def translate2():  
    translate_field.insert(10,"Two") 
def translate3():  
    translate_field.insert(10,"Three") 

root = Tk()  
    
# Set the background colour of GUI window  
root.configure(background = 'light green')  
    
# Set the configuration of GUI window  
root.geometry("400x250")  
    
# set the name of tkinter GUI window  
root.title("Translate")   
        
# Create a English Translation : label  
label1 = Label(root, text = "English Translation : ",fg = 'black', bg = 'red')  
  
# grid method is used for placing   
# the widgets at respective positions   
# in table like structure . 
  
# padx keyword argument used to set paading along x-axis . 
# pady keyword argument used to set paading along y-axis .  
label1.grid(row = 1, column = 0, padx = 10, pady = 10)   
  
# Create a text box   
# for output of translated information 
translate_field = Entry(root)   
    
translate_field.grid(row = 1, column = 1, padx = 10, pady = 10)   

button1 = Button(root, text = "Uno", bg = "red",fg = "black", command = translate1)  
button2 = Button(root, text = "Dos", bg = "red",fg = "black", command = translate2)  
button3 = Button(root, text = "Tres", bg = "red",fg = "black", command = translate3)    
# Create a Clear Button and attached   
# to clear_all function   
button4 = Button(root, text = "Clear", bg = "cyan",fg = "black", command = clear_all) 
    
button1.grid(row = 4, column = 1, pady = 10)  
button2.grid(row = 6, column = 1, pady = 10) 
button3.grid(row = 8, column = 1, pady = 10) 
button4.grid(row = 10, column = 1, pady = 10) 
  
# Start the GUI   
root.mainloop() 

Output:

I hope you find the solution helpful and insightful.

Keep Learning !


Related Solutions

A student studying for a vocabulary test knows the meanings of 12 words from a list...
A student studying for a vocabulary test knows the meanings of 12 words from a list of 22 words. If the test contains 10 words from the study list, what is the probability that at least 8 of the words on the test are words that the student knows? (Round your answer to three decimal places.)
A student studying for a vocabulary test knows the meanings of 10 words from a list...
A student studying for a vocabulary test knows the meanings of 10 words from a list of 26 words. If the test contains 10 words from the study list, what is the probability that at least 8 of the words on the test are words that the student knows? (Round your answer to three decimal places.)
python Create a dictionary and insert several English words as keys and the Pig Latin (or...
python Create a dictionary and insert several English words as keys and the Pig Latin (or any other language) translations as values. Write a function called bonus that takes as a parameter a dictionary that has names as keys and salaries as values. Your function should increase everyone’s salary in the dictionary by 5%. Write a function called updateAge that takes as parameters a list of names of people whose birthday it is today, and a dictionary that has names...
Using Python, use the following list (Temperature = [56.2,31.8,81.7,45.6,71.3,62.9,59.0,92.5,95.0,19.2,15.0]) to: - Create a loop to iterate...
Using Python, use the following list (Temperature = [56.2,31.8,81.7,45.6,71.3,62.9,59.0,92.5,95.0,19.2,15.0]) to: - Create a loop to iterate through each of the elements in the temperature list. - Convert each element of this list to a Celsius temperature and then, for each valid temperature in the list, print out both the original Fahrenheit temperature and the Celsius equivalent in this format: "32 degrees Fahrenheit is equivalent with 0 degrees Celsius."
Using Python:     "We have a list of strings: \n",     "```python\n",     "CharList = ['a',...
Using Python:     "We have a list of strings: \n",     "```python\n",     "CharList = ['a', 'b', 'c', 'd']\n",     "```\n",     "Now, we write a program to delete some elements from the list. <br> \n",     "The indexes of the elements to be deleted are stored in IndexList <br>\n",     "\n",     "```Scenario-1```: IndexList = [3, 0]\n",     "```python\n",     "CharList = ['a', 'b', 'c', 'd']\n",     "IndexList = [3, 0]\n",     "for n in range(0, len(IndexList)):    \n",    ...
Let S be the set of all natural numbers that are describable in English words using...
Let S be the set of all natural numbers that are describable in English words using no more than 50 characters (so, 240 is in S since we can describe it as “two hundred forty”, which requires fewer than 50 characters). Assuming that we are allowed to use only the 27 standard characters (the 26 letters of the alphabet and the space character), show that there are only finitely many numbers contained in S. (In fact, perhaps you can show...
Using Python, write a program that meets the following requirements: Make a list called sandwich_orders and...
Using Python, write a program that meets the following requirements: Make a list called sandwich_orders and fill it with the names of various sandwiches. Make an empty list called finished_sandwiches. Loop through the list of sandwich orders and spring a message for each order such as "I am working on your tuna sandwich" As each sandwich is made, move it to the list of finished sandwiches. After all the sandwiches have been made, print a message listing each sandwich that...
Creating a list/tuple in python 2. Using a list of lists containing X’s and O’s to...
Creating a list/tuple in python 2. Using a list of lists containing X’s and O’s to represent a tic tac toe board, write code to check if the board has a winner.
python Write a function pack_to_5(words) that takes a list of string objects as a parameter and...
python Write a function pack_to_5(words) that takes a list of string objects as a parameter and returns a new list containing each string in the title-case version. Any strings that have less than 5 characters needs to be expanded with the appropriate number of space characters to make them exactly 5 characters long. For example, consider the following list: words = ['Right', 'SAID', 'jO'] The new list would be: ['Right', 'Said ', 'Jo '] Since the second element only contains...
Python: How would I write a function using list comprehensions to list of integers into two...
Python: How would I write a function using list comprehensions to list of integers into two halves with the evens first, followed by odds? And on top of that, the numbers should be listed in their original order.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT