1

This is my first time coding with Python and for a school project we have to build an app. I am trying to finish up my create user page and its giving me the error listed below. I have researched Youtube videos and have looked through several web pages. I even bought Python Flash Cards by Eric Matthes but still cant resolve this error please explain what I am doing wrong.

ERROR:

C:\Users\Vatech\PycharmProjects\Guardian-app\venv\Scripts\python.exe C:\Users\Vatech\PycharmProjects\Guardian-app\main.py Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\Vatech\AppData\Local\Programs\Python\Python311\Lib\tkinter_init_.py", line 1948, in call return self.func(*args) ^^^^^^^^^^^^^^^^ File "C:\Users\Vatech\PycharmProjects\Guardian-app\venv\Lib\site-packages\customtkinter\windows\widgets\ctk_button.py", line 553, in _clicked self._command() File "C:\Users\Vatech\PycharmProjects\Guardian-app\main.py", line 53, in CUID_button_event2 Create_User.UserB(self) TypeError: Create_User.UserB() missing 2 required positional arguments: 'Pin' and 'CPin'

Below is my code I have tried several ways to get the information from Pin and CPin but cant get past this error the closest I have come is when it at least shows me the entry bars but then errors out.

import customtkinter
import tkinter

class Create_User(customtkinter.CTk):
    def __init__(self,*args):
       pass
    def UserB(self,Pin,CPin):

        self.Pin = customtkinter.IntVar(Pin.get())
        self.CPin = customtkinter.IntVar(CPin.get())


        self.Middle_frame = customtkinter.CTkFrame(self, width=850, height=500, corner_radius=10)
        self.Middle_frame.place(relx=0.585, rely=0.45, anchor=tkinter.CENTER)

        self.Create_User_label = customtkinter.CTkLabel(self.Middle_frame, text="Create Account", anchor="w",font=customtkinter.CTkFont(size=30, weight="bold"))
        self.Create_User_label.place(relx=0.5, rely=0.2, anchor=tkinter.CENTER)

        self.Username_entry = customtkinter.CTkEntry(self.Middle_frame, width=250, height=25, corner_radius=10,placeholder_text="Username")
        self.Username_entry.place(relx=0.5, rely=0.3, anchor=tkinter.CENTER)
        self.Pin_entry = customtkinter.CTkEntry(self.Middle_frame, width=250, height=25, corner_radius=10,placeholder_text="4 digit Pin",textvariable=Pin)
        self.Pin_entry.place(relx=0.5, rely=0.4, anchor=tkinter.CENTER)
        self.CPin_entry = customtkinter.CTkEntry(self.Middle_frame, width=250, height=25, corner_radius=10,placeholder_text="Confirm Pin", textvariable=CPin)
        self.CPin_entry.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
        self.Create_Account_Button = customtkinter.CTkButton(self.Middle_frame, text="Create Account",command=self.PinChecking_Event)
        self.Create_Account_Button.place(relx=0.5, rely=0.6, anchor=tkinter.CENTER)

    def PinChecking_Event(self):
        if self.CPin != self.Pin:
            self.Doesnotmatch_label = customtkinter.CTkLabel(self.Middle_frame, text="Pins do not match")
            self.Doesnotmatch.place(relx=0.5, rely=0.6, anchor=tkinter.CENTER)

        elif self.CPin == self.Pin:
            breakpoint()

Main Class

    from Backupbutton import Backupbutton
from Help_Button import Help_Button
from Create_User import Create_User
import customtkinter
import tkinter

customtkinter.set_appearance_mode("Dark")
customtkinter.set_default_color_theme("green")

class App(customtkinter.CTk):
    def __init__(self):
        super().__init__()
        #logo, title and window size
        self.title("Guardian")
        self.geometry("1100x580")
        self.iconbitmap("App-logo.ICO")

        #Main grid
        self.grid_columnconfigure(1, weight=1)
        self.grid_columnconfigure((2, 3), weight=0)
        self.grid_rowconfigure((0, 1, 2), weight=1)

        self.App_Name_label = customtkinter.CTkLabel(self, text="Guardian", font=customtkinter.CTkFont(size=45, weight="bold"))
        self.App_Name_label.grid(row=3, column=3, padx=20, pady=(20, 10))

#Side Menu
        self.sidebar_frame = customtkinter.CTkFrame(self, width=140, corner_radius=0)
        self.sidebar_frame.grid(row=0, column=0, rowspan=4, sticky="nsew")
        self.sidebar_frame.grid_rowconfigure(4, weight=1)
#Side Menu label
        self.logo_label = customtkinter.CTkLabel(self.sidebar_frame, text="Menu", font=customtkinter.CTkFont(size=20, weight="bold"))
        self.logo_label.grid(row=0, column=0, padx=20, pady=(20, 10))
#Side Menu buttons
        self.sidebar_button_1 = customtkinter.CTkButton(self.sidebar_frame, text="Backup", command=self.Backup_button_event1)
        self.sidebar_button_1.grid(row=1, column=0, padx=20, pady=10)
        self.sidebar_button_2 = customtkinter.CTkButton(self.sidebar_frame, text="Create User ID", command=self.CUID_button_event2)
        self.sidebar_button_2.grid(row=2, column=0, padx=20, pady=10)
        self.sidebar_button_2 = customtkinter.CTkButton(self.sidebar_frame, text="Help", command=self.Help_button_event3)
        self.sidebar_button_2.grid(row=3, column=0, padx=20, pady=10)
#Side Menu OptionMenu's
        self.appearance_mode_label = customtkinter.CTkLabel(self.sidebar_frame, text="Appearance Mode:", anchor="w")
        self.appearance_mode_label.place(relx=0.5, rely=0.85, anchor=tkinter.CENTER)
        self.appearance_mode_optionemenu = customtkinter.CTkOptionMenu(self.sidebar_frame,values=["Dark", "Light"], command=self.change_appearance_mode_event)
        self.appearance_mode_optionemenu.place(relx=0.5, rely=0.90, anchor=tkinter.CENTER)


    def change_appearance_mode_event(self, new_appearance_mode: str):
        customtkinter.set_appearance_mode(new_appearance_mode)
    def Backup_button_event1(self):
        Backupbutton.BackupB(self)
    def CUID_button_event2(self):
        Create_User.UserB(self)
    def Help_button_event3(self):
        Help_Button.helpB(self)


if __name__ == "__main__":
    app = App()
    app.mainloop()
Mahesh Thorat
  • 1
  • 4
  • 11
  • 22
Andrew R
  • 11
  • 3
  • can you include the rest of the code? Especially where you are calling the `Create_User` method. – RMT May 16 '23 at 00:08
  • Your posted code does not have the line mentioned in the error. – acw1668 May 16 '23 at 00:09
  • It is obviously that `Create_User.UserB()` requires two arguments: `Pin` and `CPin`. However I don't understand why the two arguments are required. It is better to review your design. – acw1668 May 16 '23 at 01:37
  • Here is my Git link https://github.com/Andkirel/Guardian-app.git – Andrew R May 16 '23 at 01:41
  • @acw1668 I added them but that still did not work it gave less of an error but still the following File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py", line 1921, in __call__ return self.func(*args) File "C:\Users\aruiz\PycharmProjects\pythonProject\venv\lib\site-packages\customtkinter\windows\widgets\ctk_button.py", line 553, in _clicked self._command() TypeError: App.CUID_button_event2() missing 2 required positional arguments: 'Pin' and 'CPin' – Andrew R May 16 '23 at 01:49
  • I have said in my past comment *"why the two arguments are required"* and suggest you to review your design. – acw1668 May 16 '23 at 01:55
  • So 24 hrs late and still stuck even had another class mate look at it at this point I will take any hint to what is causing my issues. I am using Pycharm for coding – Andrew R May 16 '23 at 15:55

0 Answers0