python实现按钮的背景与前景的例子,代码如下:
from Tkinter import * class Java2sButton(Frame): def __init__(self): Frame.__init__(self) self.pack() stopper = Button(self, text='Text', command=self.quit) stopper.pack() stopper.config(bg='navy', fg='white', bd=8) if __name__ == '__main__': Java2sButton().mainloop()
效果图,如下: