
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Highlight 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.
Example
Let us take an example to understand this.
# Import the library from tkinter import * # Create an instance of window win=Tk() # Set the geometry of the window win.geometry("700x350") # Create a frame frame=Frame(win) # Create two buttons save_btn=Button(frame, text="Save", default="active") save_btn.pack(side="right") cancel_btn=Button(frame, text="Cancel", default="normal") cancel_btn.pack(side="left") frame.pack(pady=50) win.mainloop()
Output
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 −