I am having trouble triggering some if-else condition with global variables when using the Toplevel
window Buttons in tkinter
.
Here is the relevant snippet of code:
from tkinter import ttk
from tkinter import *
DELETE_ENTRY_STATUS = bool
DELETE_ENTRY_NUM = 0
def messagebox():
global DELETE_ENTRY_STATUS, DELETE_ENTRY_NUM
top = Toplevel(bg = 'red')
top.geometry('210x100')
top.title('A.R.A.H')
delete_confirmation_btn = Button(top, text='Confirm',width=12,bg='brown',fg='white',command=deleteconfirmbit).pack(pady = 20)
delete_cancel_btn = Button(top, text='Cancel',width=12,bg='brown',fg='white',command=deletecancelbit).pack()
```This is where I am unable to receive the updated DELETE_ENTRY_NUM from deleteconfirmbit & deletecancelbit```
if DELETE_ENTRY_NUM == 1:
top.after(0, top.destroy)
def delete_all_option():
global DELETE_ENTRY_STATUS, DELETE_ENTRY_NUM
messagebox()
if DELETE_ENTRY_STATUS:
```Doing some Treeview Operation```
def deleteconfirmbit():
global DELETE_ENTRY_STATUS, DELETE_ENTRY_NUM
DELETE_ENTRY_STATUS = True
DELETE_ENTRY_NUM = 1
def deletecancelbit():
global DELETE_ENTRY_STATUS, DELETE_ENTRY_NUM
DELETE_ENTRY_STATUS = False
DELETE_ENTRY_NUM = 1
```Some main codes```
delete_all_option()
```Some more main codes```
I understand this is likely due to the way the function was called from this thread but I am unable to figure out how I should re-order the function call to get the DELETE_ENTRY_NUM
to be updated after deleteconfirmbit
& deletecancelbit
function calls. Thanks in advance.