我在这里的代码中重新创建了问题。我可能没有正确定义列表。
import tkinter as tk
Name=("")
j=0
AnimalNameList=["Badger","Beaver","Buffalo","Bull","Bulldog","Cobra","Curlew","Eagle","Falcon","Fox","Gannet","Hawk","Kestrel","Lion","Merlin","Otter","Owl","Panther","Peewit","Raven","Seagull","Seal","Stag","Swift","Tiger","Wolf","Woodpecker","Woodpigeon"]
for i in AnimalNameList:
j=j+1
print(i)
print(j)
root=tk.Tk()
Animals=tk.OptionMenu(root,Name,AnimalNameList)
Animals.grid(row=1,column=1)
root.mainloop()
答案 0 :(得分:1)
您可以测试它可以接受多少个值。
这是一个简单的例子:
import {Injectable} from "@angular/core";
import {HttpClient, HttpEvent, HttpHeaders, HttpParams, HttpRequest} from
"@angular/common/http";
@Injectable()
export class PrestatairesService
{
host:string = "http://localhost:8080/";
constructor(private http:HttpClient)
{
}
getAllTypes()
{
return this.http.get(this.host + "prestatairesTypes");
}
ajouterType(model:any)
{
return this.http.post(this.host + "prestatairesTypes", model);
}
getOneType(id:any)
{
return this.http.get(this.host + "prestatairesTypes/" + id);
}
ajouterPrestataires(model:any)
{
return this.http.post(this.host + "prestataires", model);
}
uploadFile(model:any)
{
let formData = new FormData();
formData.append('multipartFile', model.file);
formData.append('nom', model.nom);
formData.append('email', model.email);
formData.append('rib', model.rib);
formData.append('taches', model.taches);
formData.append('fax', model.fax);
formData.append('adresse', model.adresse);
// This is the line that cause the Error of status code 400
// What to do here to send the request correctly
formData.append('prestatairesTypes', model.prestatairesTypes);
formData.append('tele', model.tele);
let params = new HttpParams();
const options = {
params: params,
reportProgress: true,
};
const req = new HttpRequest('POST', this.host+"prestataires", formData,
options);
return this.http.request(req);
}
}
以上内容对我有用,尽管加载需要花费几秒钟。如果我尝试做70,000,它将失败。认为根据this post,列表中的max元素可能非常大,我认为限制可能是基于内存的。但是,您的问题并不是由于选择过多。
您在选项菜单上忘记了import tkinter as tk
long_list = []
for i in range(50000):
long_list.append(i)
root = tk.Tk()
Animals=tk.OptionMenu(root, "start", *long_list)
Animals.grid(row=1, column=1)
root.mainloop()
作为参数。传递选项列表时,这是必需的,否则它将为您提供一个下拉菜单项,其中列表中的所有值都排在一行中。
所以改变这个:
*
为此:
Animals=tk.OptionMenu(root,Name,AnimalNameList)
还要确保您要进行Animals=tk.OptionMenu(root,Name,*AnimalNameList)
,因为括号是必需的。