1

When I create a button like this in tkinter:

self.submition_button=Button(self.root, text='Submit', 
            font='Times 12 bold italic', command=self.onSubmition, bg='blue')

the button isn't blue.

Why isn't it blue, and what can I do to make it blue?

2 Answers2

1

Are you using tkinter.Button or are you really using ttk.Button? You'll know which one your using based on what you imported in the top of code

regular tkinter widgets importing

import tkinter

typical TTK widgets importing

from tkinter import ttk

Because TTK is more modern version of the library it's styling system is different. So setting flag options on it wont work. instead you have to use style theme.

See this reply.

https://stackoverflow.com/a/44416355/8661716

LFMekz
  • 593
  • 8
  • 10
0

This is the code for a blue button, check it :

from tkinter import *

#create a window
root =Tk()

button=Button(root, text='Submit',  font='Times 12 bold italic', bg='blue', activebackground="blue")
button.pack()
root.mainloop()
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103