[Tutor] Getting values from different functions (def's)

Susana Iraiis Delgado Rodriguez susana.delgado_s at utzmg.edu.mx
Wed Aug 31 19:17:44 CEST 2011


Hello list !!
I'm developing a Python GUI application. I alreday developed a very simple
window with buttons, each button will do a different task, but the most
important button will need to get information gotten in previous python's
functions. Let's say I have four functions but at the end I want to collet
all the information gotten.
from Tkinter import *
import tkSimpleDialog
import tkMessageBox
import tkFileDialog
def directorio():
 print 'Seleccione directorio donde empezar'
 dirname =
tkFileDialog.askdirectory(parent=root,initialdir="/",title='Selecciona la
ruta a escanear')
 if len(dirname ) > 0:
  print "You chose %s" % dirname
def extension():
 print "Escribe la extension que necesitas buscar"
 ext=tkSimpleDialog.askstring('Extension a buscar:','')
 print 'Buscando archivos: ',ext
def csv():
 print "Nombre del csv a crear"
 inv=tkSimpleDialog.askstring('Nombre de .csv:','')
 print 'Archivo de salida: ',inv
def boton4():
#In this button I want to make a bigger process, but I need the root
selected and the two strings the user types.
 print csv.inv #Obviously this throws an error
root = Tk()
top = Toplevel()
root.minsize(400,200)
toolbar = Frame(root)
b = Button(toolbar, text="Selecciona ruta", width=15, command=directorio)
b.pack(side=LEFT, padx=2, pady=2)
b = Button(toolbar, text="Escriba extension", width=15, command=extension)
b.pack(side=LEFT, padx=2, pady=2)
b = Button(toolbar, text="Nombre de csv", width=15, command=csv)
b.pack(side=LEFT, padx=2, pady=2)
b = Button(toolbar, text="Salir", width=6, command=boton4)
b.pack(side=LEFT, padx=2, pady=2)
toolbar.pack(side=TOP, fill=X)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110831/78087c90/attachment.html>


More information about the Tutor mailing list