"""
Give code for a GUI to shuffle the letters in a message.
A scrambled message is shows in an entry widget.
Each time the user presses the button,
the letters in the message are shuffled.
"""
from tkinter import Tk, Entry, END, Button
from random import shuffle

class Message(object):
    """
    GUI to shuffle a message.
    """
    def __init__(self, wdw, message) :
        """
        One entry widget to display the message,
        above the button to shuffle the message.
        """
        self.riddle = message
        self.ent = Entry(wdw, width=len(message)+2)
        self.ent.grid(row=0)
        self.btt = Button(wdw, text='press to shuffle', \
            command = self.show)
        self.btt.grid(row=1)
        self.show()

    def show(self):
        """
        Shuffles the riddle and places the
        shuffled letters in the entry widget.
        """
        shuffle(self.riddle)
        self.ent.delete(0, END)
        display = ''.join(self.riddle)
        self.ent.insert(0, display)

def main():
    """
    Defines the message and launches the GUI.
    """
    riddle = ['G', 'O', 'O', 'D', ' ', 'L', 'U', 'C', 'K']
    shuffle(riddle)
    window = Tk()
    Message(window, riddle)
    window.mainloop()

if __name__ == "__main__":
    main()
