我编写了python tkinter按钮来获得颜色,但它们没有

时间:2017-05-27 23:59:17

标签: python

在程序中,我指定按钮的文本有颜色,但它们显示为黑色,我从未收到错误消息。

这是我的代码:

from Tkinter import *

root = Tk()

topFrame = Frame(root)
topFrame.pack()
bottomFrame = Frame(root)
bottomFrame.pack(side = BOTTOM)

button1 = Button(topFrame,text = "Button 1",fg = "red")
button2 = Button(topFrame,text = "Button 2",fg = "green")
button3 = Button(topFrame,text = "Button 3",fg = "blue")
button4 = Button(bottomFrame,text = "Button 4",fg = "purple")

button1.pack(side = LEFT)
button2.pack(side = LEFT)
button3.pack(side = LEFT)
button4.pack(side = BOTTOM)

root.mainloop()

0 个答案:

没有答案