'tk registration, type error when clicking button

I've written a code for login / registration.

When ran a "sign-in page" pops up it has 2 entries(User name & Password) and 2 buttons (login, sign up). when you click login it prints the results to IDLE(even if nothing has been typed). Clicking sign up opens a page called the Registration page. It includes 3 entries (username, password, email address) ???? 2 buttons (continue and " "). I think that is supposed to be a cancel option I never finished working on.

issue appears to come from (lines30-32)

    tk.Button(reg, text="Continue", command=onSignup).grid(row=4, column=2)
    reg_cont = tk.Button(reg)
    reg_cont.grid(row=4,column=3)

Full Code

import tkinter as tk


def validate_login(username, password):
    print("username entered :", username.get())
    print("password entered :", password.get())

def onSignup(UserName,EncryptedPassword):
  f = open(UserName,"w")
  f.write(EncryptedPassword)
  f.close()

def open_win():
    reg = tk.Toplevel(root)
    reg.title("Registration Page")
    reg.geometry(f'600x400+{int(reg.winfo_screenwidth()/2-600/2)}+{int(reg.winfo_screenheight()/2-400/2)}')

    tk.Label(reg, text="User Name").grid(row=0, column=1)
    reg_un = tk.Entry(reg)
    reg_un.grid(row=0, column=2)

    tk.Label(reg, text="Password").grid(row=1, column=1)
    reg_pw = tk.Entry(reg)
    reg_pw.grid(row=1, column=2)

    tk.Label(reg, text="Email Address").grid(row=2, column=1)
    reg_email = tk.Entry(reg)
    reg_email.grid(row=2, column=2)

    tk.Button(reg, text="Continue", command=onSignup).grid(row=4, column=2)
    reg_cont = tk.Button(reg)
    reg_cont.grid(row=4,column=3)


root = tk.Tk()
root.title('Sign in Page')
root.geometry(f'600x400+{int(root.winfo_screenwidth()/2-600/2)}+{int(root.winfo_screenheight()/2-400/2)}')

tk.Label(root, text="User Name").grid(row=0, column=1)
un = tk.Entry(root)
un.grid(row=0, column=2)

tk.Label(root, text="Password").grid(row=1, column=1)
pw = tk.Entry(root, show='*')
pw.grid(row=1, column=2)

tk.Button(root, text="Login", command=lambda u=un, p=pw: validate_login(u, p)).grid(row=4, column=1)
tk.Button(root, text="Sign up", command=open_win).grid(row=4, column=2)

The issue I'm having aside from the button I dont remember adding... is when I click "continue" on the Registration page I get an error: TypeError: onSignup() missing 2 required positional arguments: 'UserName' and 'EncryptedPassword'

Nothing happens when I click the blank button (next to continue on the registration page)

this seems to point at lines(8-11)

def onSignup(UserName,EncryptedPassword):
  f = open(UserName,"w")
  f.write(EncryptedPassword)
  f.close()

I believe this is supposed to be opening a new file and writing the username/password(encrypted). and when you attempt to sign in it checks the information saved. currently don't have anything set to happen when you login.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source