这是用于导航栏的代码段
import ntpath
import tkinter as tk
from PIL import Image, ImageTk
root = tk.Tk()
root.geometry("800x600")
#for storing image references
images = dict()
#list of your image paths
pathlist = ['D:\image1.png', 'D:\image2.png']
#load paths and save references
for path in pathlist:
name = ntpath.basename(path).split('.')[0]
images[name] = ImageTk.PhotoImage(Image.open(path), name=name)
#you can assign an image with just the name
labela = tk.Label(root, image='image1')
labela.grid()
#or directly through the images reference
labelb = tk.Label(root, image=images['image2'])
labelb.grid()
root.mainloop()
我尝试将一个类分配给颜色为“白色”的'a'元素,但无法正常工作。
答案 0 :(得分:0)
使用引导文本类。
尝试对标签text-white
的类<a class="nav-link text-white" href="#">About</a>
您的代码无法正常工作,因为Bootstrap类具有更高的特异性。引导程序规则包含!important
引导程序类
.text-white {
color: #fff!important;
}