class register_frame(Tk):
def __init__(self):
super(register_frame, self).__init__()
self.minsize(500,400)
self.resizable(False,False)
self.soc = socket.socket()
self.soc.connect()
self.label_username = ttk.Label(self, text="Username")
self.label_username.place(x=90,y=50)
self.label_password = ttk.Label(self, text="Password")
self.label_password.place(x=90,y=80)
self.label_password_again = ttk.Label(self, text="Password confirm")
self.label_password_again.place(x=90,y=110)
self.label_email = ttk.Label(self, text="Email")
self.label_email.place(x=90,y=140)
self.entry_username = ttk.Entry(self)
self.entry_username.place(x=200,y=50)
self.entry_password = ttk.Entry(self, show="*")
self.entry_password.place(x=200,y=80)
self.entry_password_again = ttk.Entry(self, show="*")
self.entry_password_again.place(x=200,y=110)
self.entry_email = ttk.Entry(self)
self.entry_email.place(x=200,y=140)
self.label_2 = Label(text="email must contain @, password must be at least 4 charcters long and without spaces, username must be at least 4 charcters long and without spaces",width=20,font=("bold", 10))
self.label_2.place(x=200,y=150)
#self.checkbox = Checkbutton(self, text="Keep me logged in")
#self.checkbox.grid(columnspan=2)
self.logbtn = ttk.Button(self, text="Register", command=self._login_btn_clicked).place(x=200,y=250)
#self.pack()
def _login_btn_clicked(self):
username = self.entry_username.get()
password = self.entry_password.get()
password2 = self.entry_password_again.get()
email=self.entry_email.get()
regData = "register" + " " + username + " " + password + " " + email
if ("@" in email) == False or len(password) < 4 or (" " in password) == True or (password == password2) != True or len(username) < 4 or (" " in username) == True:
errorString = " "
if ("@" in email) == False:
errorString += "email invalid"
if len(password) < 4 or (" " in password) == True:
errorString += "\npassword invalid"
if (password == password2) != True:
errorString += "\npasswords not match"
if len(username) < 4 or (" " in username) == True:
errorString += "\nusernmae invalid"
popupmsg( errorString,'error')
else:
#here i need to send the info to the server
class Main_gui(Tk):
def __init__(self):
super(Main_gui,self).__init__()
self.title("my private radio")
self.minsize(450,450)
self.configure(background="white")
self.resizable(False,False)
def login_bt():
Login_frame()
self.destroy()
def register():
register_frame()
self.destroy()
def connection():
try:
s = socket.socket()
host = input(str("Please enter the host address of the sender : "))
port = 8080
s.connect((host,port)
print("Connected ... ")
except:
print("connection error")
exit()
ttk.Button(self,text='login',command=login_bt).place(x=200,y=200)
ttk.Button(self,text='register',command=register).place(x=200,y=225)
我需要向包含数据库的服务器发送一些用户名和密码数据。...我面临的问题是我不知道如何使用在{{ 1}}类,在我拥有的其他类中使用main_gui
函数。