How to highlight a tkinter button in macOS?

Tkinter is a Python based GUI toolkit that is used to develop desktopbased applications. You can build the different components of an application using tkinter widgets. Tkinter programs are reliable and support crossplatform mechanisms through which a particular application can run on multiple platforms and operating systems. However, there are some of functions and class libraries that work perfectly on Windows but may not work on a Linux system.

Tkinter Button widget, specifically in macOS, creates nativelooking buttons that can be customized by using the library functions and parameters available in tkinter. However, you can customize the button by highlighting it using the default parameter. This parameter sets the default color (blue) of the button that macOS supports.


Let us take an example to understand this.

# Import the library
from tkinter import *

# Create an instance of window

# Set the geometry of the window

# Create a frame

# Create two buttons
save_btn=Button(frame, text="Save", default="active")
cancel_btn=Button(frame, text="Cancel", default="normal")




Running the above code will display a frame inside which two buttons are created. Since the default color of the buttons in macOS is "blue", we can provide a default color to the specified buttons.

However, on a Windows system, the output screen would look like this −