Carlos Arronte Bello Carlos Arronte Bello - 5 months ago 31
Python Question

Call a __init__ function from another function

I need some help form all of you, so i have something like this

class LoginFrame(Frame):

def __init__(self, master):
def _login_btn_clickked(self):

result = messagebox.askyesno("Wrong username or password.", "Do you want to try again?")
if result == True:

So if the user select the option to try again i need the whole program start again, and show the login box. But when i execute the program the process fail.


But when i execute the program the process fail.

Actually it should. __init__ method is normally called once an instance is created. You need to redesign this to either recreate an instance (first call pack_forget on that frame and then make new one and pack on that place), or do it using methods, like show_loginbox etc

Usually, loginboxes are made using Toplevel with Entry as fields and some buttons to post a result. If done so, on error you could simply erase login or/and passwords entry box and show an error What I mean is:

first next

reference implementation of above is here