1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Yanka [14]
3 years ago
10

Write a GUI program that translates the Spanish words to English. The window should have three buttons, one for each Spanish wor

d. When the user clicks a button, the program displays the English translation in a label.

Computers and Technology
1 answer:
Luba_88 [7]3 years ago
5 0

Answer:

Here is the Python program:

import tkinter  #to create GUI translator application

class Spanish2English:  # class to translate Spanish words to English

 def __init__(self):  # constructor of class

   self.main_window = tkinter.Tk()  # create a main window

   self.top_frame = tkinter.Frame()  # create a frame

   self.middle_frame = tkinter.Frame()#  # create a middle frame

   self.bottom_frame = tkinter.Frame() #create a frame at bottom

   self.top_label = tkinter.Label(self.top_frame,text="Select a spanish word to translate")  #creates a label at top frame with text: Select a Spanish word to translate

   self.top_label.pack()  # to organize the widgets

   self.first_button=tkinter.Button(self.middle_frame, text="uno",command=self.word1)  

#create first button with Spanish word uno and place it in middle frame

   self.second_button = tkinter.Button(self.middle_frame, text="dos",command = self.word2)  

# create second button with Spanish text dos and place it in middle frame

   self.third_button = tkinter.Button(self.middle_frame, text="tres",command = self.word3)  

# create third button with Spanish text  tres and place it in middle frame

   self.first_button.pack(side='top')  #place first button at top

   self.second_button.pack(side='top')  #place second button next

   self.third_button.pack(side='top')  #place third button in end

   self.bottom_left_label = tkinter.Label(self.bottom_frame,text="English translation: ")  #creates label with text English translation:

   self.translation = tkinter.StringVar()  #creates String variable to hold the English translation of the Spanish words

   self.trans_label = tkinter.Label(self.bottom_frame,  textvariable=self.translation)  #creates and places label at the bottom frame which contains the English translation of Spanish words

   self.bottom_left_label.pack(side = 'left')

#organizes the labels

   self.trans_label.pack(side = 'right')

#organizes the frames

   self.top_frame.pack()

   self.middle_frame.pack()

   self.bottom_frame.pack()    

   tkinter.mainloop() #to run the application

 def word1(self): #method to translate word1 i.e. uno

   self.translation.set('one') #set the value of object to one

 def word2(self): #method to translate word2 i.e. dos

   self.translation.set('two') #set the value of object to two

 def word3(self): #method to translate word3 i.e. tres

   self.translation.set('three')  #set the value of object to three

translator = Spanish2English() #run the translator application

Explanation:

The program is well explained in the comments mentioned with each line of program

The program creates a GUI translator application using tkinter standard GUI library. In class Spanish2English first the main window is created which is the root widget. Next this main window is organized into three frames top, middle and bottom. A label is placed in the top frame which displays the text "Select a Spanish word to translate". Next, three buttons are created, for each Spanish word. The first button displays the Spanish word 'uno', second button displays the Spanish word 'dos' and third button displays the Spanish word 'tres'. Next, the two labels are created, one label is to display the text: "English translation: " and the other label is to display the English translation of the Spanish words in each button. In the last, three methods, word1, word2 and word3 are used to set the value of the translation object.

The program along with its output is attached.

You might be interested in
Why is it important to think about the programming language to use?
Sloan [31]
In think is C or B in my opinion
6 0
3 years ago
Which of the following is a sign that a website is inappropriate?
nata0808 [166]

Answer:

A

Explanation:

If you find something embarrassing, its more likely that other people with also think its embarrassing. All the other points are on the internet right now. Amazon sells things, News show information and there are political campaigns to show you there offers

3 0
3 years ago
Read 2 more answers
Technician A says that there are two types of battery cells, primary (non-rechargable) and secondary. Technician B says there ar
Scrat [10]

Technician A is correct.

Electrochemical batteries can be classified into two main categories; Primary Cells and Secondary Cells.

A primary battery or cell cannot easily be recharged after use and is usually recommended to be discarded following discharge. Most primary cells are termed dry due to their capability of utilizing electrolytes contained within absorbent material.

A secondary cell, on the other hand, can be recharged electrically to their original pre-discharge condition.

4 0
3 years ago
Read 2 more answers
Which behaviors demonstrate good netiquette? Check all that apply.
Andru [333]

Answer:

identifying yourself in a post or e-mail

writing short

respecting others privacy

Explanation:

3 0
4 years ago
If a _____ error appears when you run a macro that has worked in the past, some part of the macro code no longer makes sense to
Burka [1]
If a run-time error appears when you run a macro that has worked in the past, some part of the macro code no longer makes sense to excel, ehere run-time denotes <span> the time during which a program is running</span>
This error occurs while the program is running.
Running<span> out of memorywill results in  a </span>run-time error.
5 0
3 years ago
Other questions:
  • Why don't we get together to watch the Academy Awards?
    15·2 answers
  • People with healthy media diets:
    12·1 answer
  • Information permanently stored on a hard disk, diskette, cd-rom disk, or tape, is called ________ storage.
    8·1 answer
  • Which two technologies support the building of single-page applications? and are two technologies helpful in building single pag
    12·1 answer
  • The following is an example of what kind of loop?
    15·2 answers
  • Can you send photos through messages on here?
    6·2 answers
  • Which component of service-oriented DSS can be defined as data that describes the meaning and structure of business data, as wel
    9·1 answer
  • Which two statements are true about algorithms?
    15·2 answers
  • ) Printers today have many features that include improved quality, photo printing capabilities, digital camera connectivity, bui
    11·1 answer
  • How does the dns solve the problem of translating domain names like example.com into ip addresses?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!