Open In App

Changing the colour of Tkinter Menu Bar

Last Updated : 07 Apr, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

Prerequisites: Tkinter

Menus are an important part of any GUI. A common use of menus is to provide convenient access to various operations such as saving or opening a file, quitting a program, or manipulating data. Toplevel menus are displayed just under the title bar of the root or any other toplevel windows. 

Changing the color of menubar is not available on the Windows. This is because the menubar is not owned by Tkinter itself, but it is outsourced from other third-parties, hence providing the users limited options only. But if are using Linux, then you are all set to go. You can change the color of menubar by setting the background color and foreground color. Just read the article given below to know more in detail.

Syntax:

menubar = Menu(app, background=’#background color’, fg=’#text color’)

Here, the color to be added to the menubar is given as input to the background parameter. Given below is the proper example to do the same.

Program:

Python




# Import the library tkinter
from tkinter import *
  
# Create a GUI app
app = Tk()
  
# Set the title and geometry to your app
app.title("Geeks For Geeks")
app.geometry("800x500")
  
# Create menubar by setting the color
menubar = Menu(app, background='blue', fg='white')
  
# Declare file and edit for showing in menubar
file = Menu(menubar, tearoff=False, background='yellow')
edit = Menu(menubar, tearoff=False, background='pink')
  
# Add commands in in file menu
file.add_command(label="New")
file.add_command(label="Exit", command=app.quit)
  
# Add commands in edit menu
edit.add_command(label="Cut")
edit.add_command(label="Copy")
edit.add_command(label="Paste")
  
# Display the file and edit declared in previous step
menubar.add_cascade(label="File", menu=file)
menubar.add_cascade(label="Edit", menu=edit)
  
# Displaying of menubar in the app
app.config(menu=menubar)
  
# Make infinite loop for displaying app on screen
app.mainloop()


Output:

change menu color


Previous Article
Next Article

Similar Reads

Changing the Mouse Cursor - Tkinter
Prerequisite: Python GUI – tkinter Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. In this article, we will learn, how to change the mouse cursor in Tkinter Using Python.
2 min read
Difference Between The Widgets Of Tkinter And Tkinter.Ttk In Python
Python offers a variety of GUI (Graphical User Interface) frameworks to develop desktop applications. Among these, Tkinter is the standard Python interface to the Tk GUI toolkit. Tkinter also includes the 'ttk' module, which enhances the visual appeal and functionality of the applications. In this article, we will cover the differences, providing a
4 min read
PyQt5 - Changing border of Progress Bar
In this article we will see how to change or set the border to a Progress Bar. By default, PyQt5 provides border to the progress bar but we can change it according to our convenience. Below is how default border progress bar vs styled border progress bar looks like. In order to do this we have to change the CSS style sheet of the progress bar with
2 min read
Python | Menu widget in Tkinter
Tkinter is Python’s standard GUI (Graphical User Interface) package. It is one of the most commonly used package for GUI applications which comes with the Python itself. Menus are the important part of any GUI. A common use of menus is to provide convenient access to various operations such as saving or opening a file, quitting a program, or manipu
2 min read
Popup Menu in Tkinter
Tkinter is Python’s standard GUI (Graphical User Interface) package. It is one of the most commonly used packages for GUI applications which comes with the Python itself. Note: For more information, refer to Python GUI – tkinter Menu Widget Menus are an important part of any GUI. A common use of menus is to provide convenient access to various oper
2 min read
Right Click menu using Tkinter
Python 3.x comes bundled with the Tkinter module that is useful for making GUI based applications. Of all the other frameworks supported by Python Tkinter is the simplest and fastest. Tkinter offers a plethora of widgets that can be used to build GUI applications along with the main event loop that keeps running in the background until the applicat
5 min read
What does the 'tearoff' attribute do in a Tkinter Menu?
Prerequisite: Python GUI – tkinterMenus Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with tkinter is the fastest and easiest way to create the GUI applications. Cr
2 min read
How to create Option Menu in Tkinter ?
The Tkinter package is the standard GUI (Graphical user interface) for python, which provides a powerful interface for the Tk GUI Toolkit. In this tutorial, we are expecting that the readers are aware of the concepts of python and tkinter module. OptionMenu In this tutorial, our main focus is to create option menu using tkinter in python. As the na
3 min read
How to activate Tkinter menu and toolbar with keyboard shortcut or binding?
You might have seen the menubar and toolbar in the various desktop apps, which are opened through shortcut keys. Don’t you know how to create such a menubar and toolbar which gets opened through a shortcut key? Have a read at the article and get to know the procedure to do the same. For activating the menubar and toolbar with the shortcut key, crea
3 min read
How To Change The Title Bar In Tkinter?
Changing the title bar in Tkinter is a fundamental aspect of customizing your application's window. The title bar typically displays the name of the window and can be modified to reflect the content or functionality of your application. Here, we'll explore three different approaches to change the title bar in a Tkinter application. Change the Title
2 min read
Practice Tags :