MVC¶

HEAD-Ex Logistics and Transportation¶

HEAD-Ex Logistics and Transportation¶
def salvar_dados():
fileD = open('encomendas.txt','a')
fileD.write('Destino: ')
fileD.write('%s\n' %destino.get())
fileD.write('Descripcion: ')
fileD.write('%s\n' %descricao.get())
fileD.write('Habla a: ')
fileD.write('%s\n' %endereco.get('1.0',END))
destino.delete(0,END)
descricao.delete(0,END)
endereco.delete('1.0',END)
HEAD-Ex Logistics and Transportation¶
from tkinter import *
app = Tk()
app.title('HEAD-Ex Logística y Transporte')
app.geometry("250x180+200+100")
Label(app,text = "Destino: ").pack()
destino = Entry(app)
destino.pack()
Label(app,text = "Descripcion: ").pack()
descricao = Entry(app)
descricao.pack()
Label(app,text = "Habla a: ").pack()
endereco = Entry(app)
endereco.pack()
Button(app, text = "Salvar" , command = salvar_dados).pack()
app.mainloop()
HEAD-Ex Logistics and Transportation¶

HEAD-Ex Logistics and Transportation¶

HEAD-Ex Logistics and Transportation¶

HEAD-Ex Logistics and Transportation¶

HEAD-Ex Logistics and Transportation¶

HEAD-Ex Logistics and Transportation¶

Model is the stored data
Vision is the featured radio button
Control is the tkinter code that manages all this
Label(app, text = 'Destino: ').pack()
destino = StringVar()
destino.set(None)
Radiobutton(app, variable = destino , text = 'Cambridge , MA', value = 'Cambridge , MA').pack()
Radiobutton(app, variable = destino , text = 'Cambridge , UK', value = 'Cambridge , UK').pack()
Radiobutton(app, variable = destino , text = 'Seattle, WA', value = 'Seattle , WA').pack()
HEAD-Ex Logistics and Transportation¶

HEAD-Ex Logistics and Transportation¶
def salvar_dados():
fileD = open('encomendas.txt','a')
fileD.write('Destino: ')
fileD.write('%s\n' %destino.get())
fileD.write('Descricao: ')
fileD.write('%s\n' %descricao.get())
fileD.write('Endereco: ')
fileD.write('%s\n' %endereco.get('1.0',END))
destino.delete(0,END)
descricao.delete(0,END)
endereco.delete('1.0',END)
def ler_destinos(archivo):
destinos = []
f = open(archivo)
for linha in f:
destinos.append(linha.rstrip())
return destinos
HEAD-Ex Logistics and Transportation¶
from tkinter import *
app = Tk()
app.title('HEAD-Ex Logística e Transporte')
Label(app,text = "Destino: ").pack()
destino = StringVar()
destino.set(None)
opcoes = ler_destinos("cidades.txt")
OptionMenu(app,destino,*opcoes).pack()
Label(app,text = "Descripcion: ").pack()
descricao = Entry(app)
descricao.pack()
Label(app,text = "Habla a: ").pack()
endereco = Entry(app)
endereco.pack()
Button(app, text = "Ahorrar" , command = salvar_dados).pack()
app.mainloop()
HEAD-Ex Logistics and Transportation¶

review¶
MVC - Model, View, Control
Entry()
Texto()
StringVar()
RadioButton()
OptionMenu()
You have attempted of activities on this page