Aug-27-2022, 09:24 AM
Hi, I have this code but i get the error "object has no attribute".
Thankfull for all help.
Kind regards
Tom
from tkinter import *
root = Tk()
root.geometry("300x300")
count = 20
pop_label = None
def ACdriver(option):
# pop.destroy()
global count
if option == "UP":
count = count + 1
else:
count = count - 1
my_label.config(text=count)
pop_label.config(text=count)
def ACwindowdriver():
global pop
pop = Toplevel(root)
pop.title("My Popup")
pop.geometry("150x200+00+00")
pop.overrideredirect(True) #Borderless
pop.config(bg="black")
pop_label = Label(pop, bg="green", fg="white", font=("helvetica", 12))
pop_label.config(text=count)
pop_label.grid(row=1, column=0, pady=10)
my_frame = Frame(pop, bg="black")
my_frame.grid(row=1, column=1, pady=10)
heatdriver = Button(my_frame, command=lambda: ACdriver("UP"), bg="black")
heatdriver.grid(row=2, column=2, pady=10)
colddriver = Button(my_frame, command=lambda: ACdriver("DOWN"), bg="black")
colddriver.grid(row=3, column=2, pady=10)
def destroy():
pop.destroy()
destroy_button = Button(root, text="destroy", command=destroy)
destroy_button.place(x=1, y=1)
ACdriver_button = Button(root, text="ACwindowdriver", command=ACwindowdriver)
ACdriver_button.pack(pady=50)
my_label = Label(root, text="")
my_label.pack(pady=20)
root.mainloop()I am trying to update the number inside the new tk window called "pop" but the number only updates after i press "destroy" and "ACwindowdriver" again. When i press one button inside the window pop i get the error "'NoneType' object has no attribute 'config'".Thankfull for all help.
Kind regards
Tom
