I wrote a login/sign up system in python using Tkinter. The code is something like:
class Sign_Up:
def __init__(self, root):
self.root = root
root.geometry('500x500')
self.name = StringVar()
...
label_0 = Label(root, ...)
entry_0 = entry(root, text = name)
...
self.b = Button(root, command = flag, ...)
self.mainloop()
def flag(self):
name1 = self.name.get()
...
Flag function checks whether the username is available or passwords match and shows relative messages from tkinter.mesagebox.
Everything works fine and desired when I call the function below:
def signup():
root = Tk()
s = Sign_Up(root)
signup()
However, when I write another class Menu which is a class for a window that has 2 buttons: Sign up and Sign in and pass this function to its button command, it does not work:
class Menu:
def __init__(self, root):
self.root = root
...
self b1 = (root, command = signup, ...)
root.mainloop()
def signup(self):
root = Tk()
s = Sign_Up(root)
Sign up function does not work with command and I assume that the problem is about get function in the flag function above because every time it shows a warning 'fill in the blanks' which is supposed to be displayed when the length of the entries is 0.
As I said, flag function and sign up class works properly independently, but it does not work when I pass it to tkinter button command. How can I fix this?