使用pip install PIL -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com安装PIL
显示looking in indexs:http://pypi.douban.com/simple/
error:could not find a version that satisfies the requirement PIL
该如何解决
http://pypi.douban.com/simple/ 这里边有问题,换个镜像试试?
根据参考资料中的提示,PIL库已经更名为pillow,所以应该使用以下命令来安装:
pip install pillow -i http://pypi.douban.com/simple/
如果安装速度过慢,可以加上 --trusted-host
参数来解决,例如:
pip install pillow -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
如果安装后在使用时提示缺少相关模块,可以通过在Python文件中导入以下代码解决:
import urllib3
urllib3.disable_warnings()
最后,如果需要在Tkinter窗口中增加下拉选项框,可以使用以下代码:
import tkinter
from tkinter import ttk
def go(*args):
print(comboxlist.get())
win=tkinter.Tk()
comvalue=tkinter.StringVar()
comboxlist=ttk.Combobox(win,textvariable=comvalue)
comboxlist["values"]=("1","2","3","4")
comboxlist.current(0)
comboxlist.bind("<<ComboboxSelected>>",go)
comboxlist.pack()
win.mainloop()
其中 comboxlist["values"]
用于设置下拉选项, comboxlist.current(0)
用于设置初始选中项, comboxlist.bind("<<ComboboxSelected>>",go)
用于绑定选中事件。具体解释请见代码注释。