Nia
Nia

Reputation: 3

(Tkinter) How to get entry button to appear after button is clicked?

I want the user to enter a value after clicking a button. I tried to define the entry within the function for clicking the button but nothing appears? The labels change when the button is clicked as per what I configured them to in the function but the entry does not appear.

def jan():
    Birth_Month = "January"
    January.forget()
    February.forget()
    March.forget()
    April.forget()
    May.forget()
    June.forget()
    July.forget()
    August.forget()
    September.forget()
    October.forget()
    November.forget()
    December.forget()
    Title.configure(text="So you were born in January")
    Month.configure(text="What date in January?")
    Date = tkinter.Entry(window)
    Birth_Date = Date.get()
    Birth_Date = Birth_Date.int()

Upvotes: 0

Views: 581

Answers (1)

Lafexlos
Lafexlos

Reputation: 7735

For your widget to show up, you need to use one of the geometry managers (pack, grid, place) on your object.

Date = tkinter.Entry(window)
Date.pack() # or grid, place depending on rest of your code

Also, to not create new Entry every time, you should create Entry outside of your function in global scope and pack it inside of your function.

Date = tkinter.Entry(window) # somewhere in your code that is accessible to your method

def jan():
    Date.pack()

Upvotes: 2

Related Questions