How to style and customize tkinter/guizero menu bar? How to style and customize tkinter/guizero menu bar? tkinter tkinter

How to style and customize tkinter/guizero menu bar?


I have broken down the following code. You do need to import tkinter first or it will throw an error.

from tkinter import * from guizero import *#background can be set rgb values,color name, and hex values# width and height set the defualt startup window sizeapp=App(title='Test',bg=(53, 60, 81),width=500,height=500)#sets min and max size of windowapp.tk.minsize(width=250,height=250)app.tk.maxsize(width=550,height=550)root = app.tk#Basic test functiondef hello():    print ("hello!")                    #creates the menubar and sets the location to root windowmenubar = Menu(root,relief=FLAT,bd=0)'''bg sets the menubar background colorfg sets the text coloractivebackground sets the selected item backgroundactiveforeground set the selected item text coloractive borderwidth removes the 3d effect/border around itemfont sets the font type and sizeDefualt text,background and other things can be set with variables'''menubar.config(bg = "GREEN",fg='white',activebackground='red',activeforeground='purple',activeborderwidth=0,font=("Verdana", 12))# create a pulldown menu, and add it to the menu bar# background,foreground and bother border and active border width needs to be set to remove any 3d border effectfilemenu = Menu(menubar, tearoff=0,relief='flat', bd=0,activebackground='red',activeborderwidth=0,font=("Verdana", 12))filemenu.config(bg = "GREEN") filemenu.add_command(label="New", command=hello)filemenu.add_command(label="Save", command=hello)#add line between drop down menu itemsfilemenu.add_separator()filemenu.add_command(label="Exit", command=root.quit)# sets the top level menu list namemenubar.add_cascade(label="File", menu=filemenu)# create a pulldown menu, and add it to the menu bar#example of no styling added to the sub menueditmenu = Menu(menubar, tearoff=0)editmenu.add_command(label="Cut", command=hello)editmenu.add_command(label="Copy", command=hello)editmenu.add_command(label="Paste", command=hello)# sets the top level menu list namemenubar.add_cascade(label="Edit", menu=editmenu)# create a pulldown menu, and add it to the menu bar# show custom effects can be add to each sub menu helpmenu = Menu(menubar, tearoff=0,bg='orange')helpmenu.add_command(label="Report bug", command=hello)helpmenu.add_command(label="About", command=hello)# sets the top level menu list namemenubar.add_cascade(label="Help", menu=helpmenu)# example of guizero widgetbox = Box(app,height=200,width=500)box.set_border(thickness=2, color='green')box.bg=(53, 60, 81)box.text_color='white'exampel_text = Text(box, text="Hello World")Picture(box,"example.png")# display the menu and other thingsroot.config(menu=menubar)app.display()