-1

I am working on a project based on GUI working on python. In the button command on passing the method of the self class there is no effect i.e the method is not getting called. there is no compile time or runtime error showing up because of which it is very difficult to identify the problem. The source code is:

class PageTwo(tk.Frame):

def e_detail(self):
    soh_registeration.insert(u1.get(),p1.get(),s1.get(),m1.get(),em1.get(),ad1.get())
    messagebox.showinfo("DETAIL STORED", "YOUR INFORMATION IS STORED SECURELY")

def __init__(self, parent, controller):
    tk.Frame.__init__(self, parent)
    label = tk.Label(self, text="REGISTERATION DETAILS", font=LARGE_FONT)
    label.grid(pady=10,padx=10)
    label1 = tk.Label(self, text="USERNAME", font=TEXT)
    label1.grid(row=3,column=0)
    labelp = tk.Label(self, text="PASSWORD", font=TEXT)
    labelp.grid(row=4,column=0)
    cpdl = tk.Label(self, text="CONFIRM PASSWORD", font=TEXT)
    cpdl.grid(row=5,column=0)
    shopl = tk.Label(self, text="SHOP NAME", font=TEXT)
    shopl.grid(row=6,column=0)
    cl= tk.Label(self, text="MOBILE NO.:", font=TEXT)
    cl.grid(row=7,column=0)
    el = tk.Label(self, text="E-MAIL ID", font=TEXT)
    el.grid(row=8,column=0)
    al = tk.Label(self, text="AADHAR DETAIL", font=TEXT)
    al.grid(row=9,column=0)

    global u1,p1,p2,s1,m1,em1,ad1,button2
    u1=tk.StringVar()
    username= tk.Entry(self,textvariable=u1, bd=5)
    username.grid(row=3,column=1)

    p1=tk.StringVar()
    pd= tk.Entry(self,show='*',textvariable=p1, bd=5)
    pd.grid(row=4,column=1)

    p2=tk.StringVar()
    confpd= tk.Entry(self,show='*',textvariable=p2, bd=5)
    confpd.grid(row=5,column=1)

    s1=tk.StringVar()
    sn= tk.Entry(self,textvariable=s1, bd=5)
    sn.grid(row=6,column=1)

    m1=tk.StringVar()
    cn= tk.Entry(self,textvariable=m1, bd=5)
    cn.grid(row=7,column=1)

    em1=tk.StringVar()
    email= tk.Entry(self,textvariable=em1, bd=5)
    email.grid(row=8,column=1)

    ad1=tk.StringVar()
    an= tk.Entry(self,textvariable=ad1, bd=5)
    an.grid(row=9,column=1)




    button2 = tk.Button(self, text="SUBMIT YOUR DETAILS",
                        command=lambda: self.e_detail)
    button2.grid(row=10, column=0, padx=20, pady=20)

as the source code is too long the two blocks where i am finding the problem are mentioned below separately too:

def e_detail(self):
    soh_registeration.insert(u1.get(),p1.get(),s1.get(),m1.get(),em1.get(),ad1.get())
    messagebox.showinfo("DETAIL STORED", "YOUR INFORMATION IS STORED SECURELY")

and:-

 button2 = tk.Button(self, text="SUBMIT YOUR DETAILS",
                        command=lambda: self.e_detail)
 button2.grid(row=10, column=0, padx=20, pady=20)

i guess the problem would be very basic. I am still new to python programming someone please help me out.

Ayush Mishra
  • 19
  • 1
  • 1
  • 3
  • Possible duplicate of [How to pass arguments to a Button command in Tkinter?](https://stackoverflow.com/questions/6920302/how-to-pass-arguments-to-a-button-command-in-tkinter) – Nae Mar 17 '18 at 07:53

1 Answers1

1

The problem seems to be that self.e_detail is not called.

, command=lambda: self.e_detail

basically tells the button to call an anonymous method that mentions a method named self.e_detail. Instead make it call the method by replacing it with:

, command=lambda: self.e_detail()

or since the method is not passed any arguments, simply:

, command=self.e_detail
Nae
  • 14,209
  • 7
  • 52
  • 79