from tkinter import *
root = Tk()
root.geometry("300x250")
root.configure(bg="Gray")
root.resizable(False,False)
root.title("Palavra Invertida")
def action():
word = variavel.get()
reversed_word = ""
for x in word:
reversed_word = x + reversed_word
lblResult['text'] = reversed_word
texto = Label(text="Digite a Palavra ",font=("Arial","15","bold"),
bg="Gray",fg="Blue")
texto.place(relx=0.25,rely=0.2)
variavel = StringVar()
entrada = Entry(textvariable=variavel,justify='center',fg="green")
entrada.place(relx=0.05,rely=0.35,relwidth=0.9)
lblResult = Label(text = "result .......",bg="Gray")
lblResult.place(relx=0.4 ,rely=0.65)
btnAction = Button(root, text = "Validate",font=("Arial","12","bold"),
fg="black",bg="blue",command=action)
btnAction.place(relx=0.35,rely=0.45)
root.mainloop()
# Outra Versão
from tkinter import *
root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Inverter as palavras") titulo = Label(text="Inverter as palavras",
font=("Arial", "25", "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.13, rely=0.05) sub1 = Label(text="Palavra: ", font=("Arial", "18", "bold"), bg="#103030", fg="#49e3e3")
sub1.place(relx=0.1, rely=0.25)
Palavra = StringVar()
Palavra_entrada = Entry(textvariable=Palavra, font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Palavra_entrada.place(relx=0.4, rely=0.26, relwidth=0.53)
Palavra_entrada.focus()
def limpar():
Palavra_entrada.delete(0,END) def app():
word=Palavra.get()
a=word[::-1]
resultado_texto.config(text=a) but1 = Button(text="Mostrar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.1, rely=0.45, relwidth=0.25, relheight=0.1) but_limpar = Button(text="Limpar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=limpar)
but_limpar.place(relx=0.4, rely=0.45, relwidth=0.25, relheight=0.1) but_sair = Button(text="Sair", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=root.destroy)
but_sair.place(relx=0.7, rely=0.45, relwidth=0.25, relheight=0.1) resultado_texto = Label(font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.65, relwidth=0.9, relheight=0.25)
root.mainloop()