Python Forum
[Tkinter] tkinter.Menu – How to make text-variable?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] tkinter.Menu – How to make text-variable?
#2
You could build a new menu. That may be the easiest way since you can probably do this without changing any of the code, just pass in a different set of labels.

You can configure menu entries, just like buttons and labels and the like. This code changes a "Quit" label to "Exit" in the file_menu.
import tkinter as tk

root = tk.Tk()
menubar = tk.Menu(root)
file_menu = tk.Menu(menubar, tearoff=False)
file_menu.add_command(label='Print', command=lambda: print("Hello World"))
file_menu.add_command(label='Quit', command=quit)
menubar.add_cascade(label='File', menu=file_menu)
root.configure(menu=menubar)
file_menu.entryconfig(1, label='Exit')
root.mainloop()
Reply


Messages In This Thread
RE: tkinter.Menu – How to make text-variable? - by deanhystad - Mar-08-2021, 04:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  update text variable on label with keypress knoxvilles_joker 5 8,085 May-31-2024, 02:09 PM
Last Post: menator01
  make widgets disappear from tkinter jacksfrustration 12 6,371 Feb-06-2024, 03:58 PM
Last Post: deanhystad
  pass a variable between tkinter and toplevel windows janeik 9 6,818 Oct-05-2023, 04:22 AM
Last Post: janeik
  [Tkinter] Updating tkinter text BliepMonster 5 12,624 Nov-28-2022, 01:42 AM
Last Post: deanhystad
  [Tkinter] The Text in the Label widget Tkinter cuts off the Long text in the view malmustafa 4 11,035 Jun-26-2022, 06:26 PM
Last Post: menator01
  Why I am getting ModuleNotFoundError when I make an Exe file for tkinter GUI? pymn 0 2,339 Apr-01-2022, 05:36 PM
Last Post: pymn
  [Tkinter] Update variable using tkinter entry methon drSlump 6 8,126 Oct-15-2021, 08:01 AM
Last Post: drSlump
  tkinter change the text of the checkbox zazas321 1 5,582 Sep-17-2021, 06:19 AM
Last Post: zazas321
  [Tkinter] It it possible to make a help file explorer with tkinter? Clunk_Head 0 2,763 Aug-07-2021, 06:02 PM
Last Post: Clunk_Head
  [Tkinter] Make my button text update? Skata100 1 2,889 Aug-07-2021, 05:37 AM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020