Please keep response replies to the Python list (e.g., use 'reply all' or just send the email to python-list).
Also, you should tell people what Python version you are using. I assume you are using Python 2 since Tkinter was renamed to tkinter in Python 3. Finally, do not top-post. Type your responses inside the body of the email you are responding to. That gives people context for your responses. On Tue, Apr 2, 2013 at 11:48 AM, Renato Barbosa Pim Pereira < renato.barbosa.pim.pere...@gmail.com> wrote: > Sorry for my inconsistence: > > I need a textbox to get one number and pass for variable called numero > with one click of button. Thanks . > > I have this: > > import numpy as np > import matplotlib.pyplot as plt > from Tkinter import * > import tkMessageBox > > prefixo = "vetor" > numero = 10 > numeroVetores = 0 > > def makeWidgets(numero): > global entries > window = Tk() > window.title('Vetores') > form = Frame(window) > form.pack() > entries = {} > for ix in range(numero): > label = "%s %s" % (prefixo , ix + 1) > lab = Label(form, text=label) > ent = Entry(form) > lab.grid(row=ix, column=0) > ent.grid(row=ix, column=1) > entries[label] = ent > > > > > > Button(window, text="Calcular", command=calcular).pack(side=LEFT) > Button(window, text="Media", command=media).pack(side=LEFT) > > > > return window > > > > def pegavalores(): > valores = [] > for chave, entrada in sorted(entries.items()): > valores.append(entrada.get()) > > return valores > > > def calcular(): > calcular = pegavalores() > plt.plot(calcular) > plt.show() > > def media(): > media = pegavalores() > elementos = len(media) > media = np.asarray(media, dtype=np.float64) > valormedio = np.sum(media)/elementos > tkMessageBox.showinfo("Media", valormedio) > > > window = makeWidgets(numero) > window.mainloop() > I'm not sure exactly what you are trying to do. My guess is that you want to get "numero" from user input. Luckily, the tkSimpleDialog module contains a handy function that does just this: askinteger. So add a call: numero = tkSimpleDialog.askinteger('Window Title', 'Please insert the number of input values you want') window = makeWidgets(numero) window.mainloop() I leave to you the task of bringing tkSimpleDialog into your namespace. Good luck, Jason -- Jason M. Swails Quantum Theory Project, University of Florida Ph.D. Candidate 352-392-4032
-- http://mail.python.org/mailman/listinfo/python-list