Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Python 3.0 There are \"Programming Exercises\" for Chapter 13 on pages 562-563 i

ID: 672303 • Letter: P

Question

Python 3.0

There are "Programming Exercises" for Chapter 13 on pages 562-563 in the course text. Your assignment is to write a GUI program named program131.py for Exercise 2, but make it Spanish to English, not Latin to English. You choose the three (or more if you like) Spanish words to translate. NOTE: The English translation should display in a label, not in a new popup window.

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


Latin: English:
sinister left
dexter right
medium center

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

Explanation / Answer

from Tkinter import *
class Spanish:
def __init__(self, master):
    frame = Frame(master)
    frame.pack()
    self.button = Button(frame,
                         text="izquierda", fg="green",
                         command=self.translate1)
    self.button.pack(side=LEFT)

    self.slogan = Button(frame,
                         text="derecho", fg="red",
                         command=self.translate2)
    self.slogan.pack(side=LEFT)

    self.slogan = Button(frame,
                         text="derecho", fg="yellow"
                         command=self.translate3)
    self.slogan.pack(side=LEFT)


def translate1(self):
    print "Left"

def translate2(self):
    print "Right"

def translate3(self):
    print "Center"


translate = Tk()
app = Spanish(translate)
translate.mainloop()