I am trying to get the following code to work, could any point out where I am going wrong?
The object is to set the menu state to disabled when a new form is loaded and then to set the menu state back to normal once the form is closed. The purpose of doing this is to only have one form (menu item) open at a time.
Any suggestions on how to achieve this would be appreciated.
Menutest
from tkinter import *
import BackupData
window = Tk()
Window_X = 600
Window_Y = 700
Screen_X = window.winfo_screenwidth()
Screen_Y = window.winfo_screenheight()
ScnDisp_X = int ((Screen_X/2) - (Window_X/2))
ScnDisp_Y = int ((Screen_Y/2) - (Window_Y/2))
window.geometry("%dx%d+%d+%d" % (Window_X,Window_Y,ScnDisp_X,ScnDisp_Y, ))
window.configure(bg="#EDF9EB") #green background
def BackupFun():
#MenuDisable()
menubar.entryconfig(1, state = DISABLED)
BackupData.BackupMod(window)
menubar.entryconfig(1, state = NORMAL)
menubar = Menu(window, bg="#333333")
window.config(menu=menubar)
# Admin Menu
ADM = Menu(menubar, tearoff=0, activebackground ="#333333", bg= "#BCC6CC")
menubar.add_cascade(label="Admin", menu=ADM )
ADM.add_command(label="Backup Data", command=BackupFun, state="normal")
ADM.add_separator()
ADM.add_command(label="Check for updates", command=None, state="disabled")
ADM.add_separator()
ADM.add_command(label="Exit", command=window.destroy)
window.mainloop()type here
Backup module
from tkinter import *
def BackupMod(window):
global fr0
FrmWidth = 200
FrmHeight = 100
fr0 = Frame(window, borderwidth=2, width=FrmWidth, height=FrmHeight, relief="ridge" )
fr0.grid(padx=20, pady=30)
button = Button(fr0, text="Close", command= Closefr0, width=10)
button.grid (row=1, column=2, sticky="news", padx=20, pady=20)
def Closefr0():
fr0.destroy()
your text