I'm creating a small app that just gets jokes from an API using ttkbootstrap. The problem is there are 2 windows showing when I run the app. Anyone know what I'm doing wrong?
Here's the code:
import requests
import ttkbootstrap as tb
from ttkbootstrap.constants import *
def get_joke():
url = "https://icanhazdadjoke.com"
headers = {'Accept': 'application/json'}
joke_time = requests.get(url, headers=headers).json().get('joke')
label.config(text=joke_time)
print(joke_time)
label = tb.Label(text="", font=("Poppins", 16), bootstyle='default')
label.pack(padx=5, pady=10)
btn = tb.Button(text="Get Joke!", command=get_joke)
btn.pack(padx=5, pady=10)
if __name__ == '__main__':
app = tb.Window(themename='darkly')
app.title('Joke App')
app.geometry('1280x900')
app.mainloop()