-
-
Save turicas/4288101 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
import io | |
import unicodedata | |
from Tkinter import * | |
def salvar_dados(): | |
valor_nome = nome.get() # retorna objeto unicode | |
valor_categoria = categoria.get() # retorna objeto unicode | |
valor_endereco = endereco.get('1.0', END) # retorna objeto unicode | |
with io.open('dados.txt', 'a', encoding='utf-8') as dados: | |
dados.write(u'''Nome: {}\nCategoria: {}\nEndereço: {}\n'''\ | |
.format(valor_nome, valor_categoria, valor_endereco)) | |
nome.delete(0, END) | |
categoria.delete(0, END) | |
endereco.delete('1.0', END) | |
nome.focus() | |
custom_msg.set('Dados salvos com sucesso!') | |
app = Tk() | |
app.title('Cadastro de entregas') | |
custom_msg = StringVar() | |
custom_msg.set('Cadastre os dados de entrega.') | |
msg = Label(app, textvariable=custom_msg) | |
msg.pack(padx=10, pady=10) | |
Label(app, text='Nome').pack(padx=10) | |
nome = Entry(app) | |
nome.pack(padx=10, pady=10) | |
nome.focus() | |
Label(app, text='Categoria').pack(padx=10) | |
categoria = Entry(app) | |
categoria.pack(padx=10, pady=10) | |
Label(app, text=u'Endereço').pack(padx=10) | |
endereco = Text(app) | |
endereco.pack(padx=10, pady=10) | |
salvar = Button(app, text='Salvar', command=salvar_dados) | |
salvar.pack(padx=10, pady=10) | |
app.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment