我需要一个滚动条在元素下滚动,看到当从第一个窗口创建超过 30 个元素时,屏幕没有填充正确的模式:
import numpy as np
import matplotlib.pyplot as plt
from Tkinter import *
import tkMessageBox
import tkSimpleDialog
from matplotlib import pylab
prefixo = "vetor"
def makeWidgets():
global entries
window = Tk()
window.title('Vetores')
form = Frame(window)
form.pack()
entries = {}
numero = tkSimpleDialog.askinteger("Vetores", "Digite o numero de vetores a serem usados:")
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="Histograma", command=histograma).pack(side=LEFT)
Button(window, text="Media", command=media).pack(side=LEFT)
Button(window, text="Mediana", command=mediana).pack(side=LEFT)
window.mainloop()
def pegavalores():
valores = []
for chave, entrada in sorted(entries.items()):
valores.append(entrada.get())
valores = np.asarray(valores, dtype=np.float64)
return valores
def histograma():
histograma = pegavalores()
pylab.grid(True)
plt.hist(histograma)
plt.show()
def media():
media = pegavalores()
elementos = len(media)
valormedio = np.sum(media)/elementos
tkMessageBox.showinfo("Media", valormedio)
def mediana():
mediana = pegavalores()
resultado = np.median(mediana)
tkMessageBox.showinfo("Mediana", resultado)
window = makeWidgets()