How to create menu and message widget in GUI using python?

Description

To create menu and message widget in python3.

Menu widget

   It is used to create all kinds of menus used by the application.

Syntax:

  M=Menu(root, options=value)

Message widget

   The widget can be used to display short text messages.

Syntax:

   M=Message(root, options=value)

#import tkinter

import tkinter as tk

from tkinter import *

 

#root window

root = tk.Tk()

menu = Menu(root)

root.config(menu=menu)

 

#menu widget

filemenu = Menu(menu)

menu.add_cascade

(label=’File’, menu=filemenu)

filemenu.add_command(label=’New’)

filemenu.add_command(label=’Open’)

filemenu.add_separator()

filemenu.add_command

(label=’Exit’, command=root.quit)

helpmenu = Menu(menu)

menu.add_cascade

(label=’Help’, menu=helpmenu)

helpmenu.add_command

(label=’About’)

tk.mainloop()

Leave Comment

Your email address will not be published. Required fields are marked *

clear formSubmit