YusufChowdhury
YusufChowdhury

Reputation: 349

Tkinter: New window has nothing in it even after writing code for it

The user clicks on "Register", and then a new window appears however nothing is in it.

Here is my code, I thought this would make everything appear?

    def create_regwindow(self):
      t = tk.Toplevel(self)
      t.wm_title("Register")
      t.field_user = tk.Label(self, text="Username")
      t.field_pass = tk.Label(self, text="Password")

      t.entry_user = tk.Entry(self)
      t.entry_pass = tk.Entry(self, show="*")

      t.field_user.grid(row=0, sticky=tk.E)
      t.field_pass.grid(row=1, sticky=tk.E)
      t.entry_user.grid(row=0, column=1)
      t.entry_pass.grid(row=1, column=1)

Upvotes: 0

Views: 76

Answers (1)

Lafexlos
Lafexlos

Reputation: 7735

You are setting parents as self. You should use t as parent on new widgets to make them appear on t.

t.field_user = tk.Label(t, text="Username") 
t.field_pass = tk.Label(t, text="Password")

Upvotes: 2

Related Questions