2

I am learning Python. I use tkinter for gui.

I am unable to set foreground and background color in a button.

import sys

import tkinter as tk

root = tk.Tk()
root.title("Sandwich")

root.geometry("500x250+800+100")

def helloButton():
    print('hello button')

myLabel1 = tk.Label(text="Label one",fg='red',bg='green').grid(row=0,column=0,sticky='w')

myButton1 = tk.Button(text="Enter",activebackground='red',bg="blue",command=helloButton).grid(row=0,column=1)

tk.mainloop()

Button does not shows foreground and background color when render. Please advice. enter image description here

raju
  • 6,448
  • 24
  • 80
  • 163

0 Answers0