MVC¶

HEAD-Ex Logística y Transporte¶

HEAD-Ex Logística y Transporte¶
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 Logística y Transporte¶
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 Logística e Transporte¶

HEAD-Ex Logística y Transporte¶

HEAD-Ex Logística y Transporte¶

HEAD-Ex Logística y Transporte¶

HEAD-Ex Logística y Transporte¶

HEAD-Ex Logística y Transporte¶

Modelo son los datos almacenados
Vision es el botón de radio presentado
Control es el código tkinter que gestiona todo esto
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 Logística e Transporte¶

HEAD-Ex Logística e Transporte¶
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 Logística e Transporte¶
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 Logística y Transporte¶

revisión¶
MVC - Modelo, Visión, Control
Entry()
Texto()
StringVar()
RadioButton()
OptionMenu()
You have attempted of activities on this page