My Tkinter library buttons/buttons are not showing

Asked

Viewed 45 times

0

I am studying the Tkinter library a little while ago,I started to create this code, when I create the first function "start" the code until it opens the window, but the Labels and button q I declare in it, do not appear . -. Can someone show me some way to create this program, or show me what I’m missing or some other way?

from tkinter import *

def iniciar():

    janela2 = Tk()
    janela2.title("Janela de usuário")

    jlabel = Label(janela2, text="Não está aparecendo")
    janela2.geometry('300x300')

    janela = Tk()

    janela.title("Janela Principal")

    l1 = Label(janela, text="Login: ")
    l2 = Label(janela, text="Senha: ")
    b1 = Button(janela, text="CONFIRMAR", command=iniciar)

    b1.grid(row=2, column=1)
    l1.grid(row=0, column=0)
    l2.grid(row=1, column=0)

    ed1 = Entry(janela, )
    ed2 = Entry(janela, )
    ed1.grid(row=0, column=1)
    ed2.grid(row=1, column=1)

    janela.geometry("250x100+500+250")
    janela.mainloop()

1 answer

1


Is missing using the pack() for objects to appear.

For example:

jlabel = Label(janela2, text="Não está aparecendo")
jlabel.pack()

In addition, you can choose the position, passing it as a parameter, in the model:

jlabel = Label(janela2, text="Não está aparecendo")
jlabel.pack(side=LEFT) # pode substituir por RIGHT, TOP e BOTTOM

Browser other questions tagged

You are not signed in. Login or sign up in order to post.