- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 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()
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 −
- Related Articles
- How to display a tkinter application in fullscreen on macOS?
- How to highlight text in a tkinter Text widget?
- How to Disable / Enable a Button in TKinter?
- How to update a Button widget in Tkinter?
- How to highlight the current line of a Text widget in Tkinter?
- How to create a Tkinter toggle button?
- How to bind a key to a button in Tkinter?
- How to handle a Button click event in tkinter?
- How to pass arguments to a Button command in Tkinter?
- How to create a Button on a Tkinter Canvas?
- How to use an Image as a button in Tkinter?
- How To Dynamically Resize Button Text in Tkinter?
- How to stop a loop with a stop button in Tkinter?
- How to exit from Python using a Tkinter Button?
- How to use Bitmap images in Button in Tkinter?