单击后按钮没有升起
Button didn't raised after clicked
这是我家Window的应用。
这是单击“登录”按钮后我的应用程序的Window。
现在,如您所见,按钮没有升起。
我附上了点击按钮后发生的事情的代码片段。
self.org_frame=Frame(self.root,relief=RIDGE,bd=4,bg="#F7DC6F")
self.org_frame.pack()
self.org_lbl=Label(self.org_frame,text="Organisation ID",fg="black",bg="#F7DC6F" ,font=("helvetica","18","bold"))
self.org_lbl.grid(row=0,column=0)
self.txt_org=Entry(self.org_frame,width=12,textvariable=self.organisation_id, font=("times new roman",18,"bold"),bd=5)
self.txt_org.grid(row=0,column=1,pady=10,padx=20)
self.org_lbl=Label(self.org_frame,text="Password",fg="black",bg="#F7DC6F" ,font=("helvetica","18","bold"))
self.org_lbl.grid(row=1,column=0)
self.txt_org=Entry(self.org_frame,width=12,show='•',textvariable=self.organisation_log_password_var, font=("times new roman",18,"bold"),bd=5)
self.txt_org.grid(row=1,column=1,pady=10,padx=20)
self.new_btn=Button(self.org_frame,text="New? Sign Up!",width=12,font=("times new roman",16,"bold"),bd=3,cursor="hand2",bg="orange",command=self.new_def)
self.new_btn.grid(row=2,column=0,padx=10,pady=10)
self.log_btn=Button(self.org_frame,text="Log In",width=10,font=("times new roman",12,"bold"),bd=3,cursor="hand2",bg="lightgreen",fg="green")
self.log_btn.grid(row=2,column=1,padx=10,pady=10)
self.log_btn.bind("<Button-1>",self.org_log)
self.root.bind("<Return>",self.org_log)
def new_def(self):
messagebox.showinfo("New Account!","To create new Organisation kindly mail us your request\nat aakarsh2504@gmail.com.")
def org_log(self,event):
if str(self.organisation_id.get()).lstrip()!="" and str(self.organisation_log_password_var.get()).lstrip()!="":
try:
int(self.organisation_id.get())
try:
con=mysql.connector.connect(host=self.developer_host,user=self.developer_user_id,port=self.developer_port,password=self.developer_password,database=self.developer_database)
cur=con.cursor()
cur.execute("select host from data where id="+self.organisation_id.get())
self.host=(cur.fetchone())[0]
cur.execute("select user from data where id="+str(self.organisation_id.get()))
self.oragnisation_user_id=(cur.fetchone())[0]
cur.execute("select db_password from data where id="+self.organisation_id.get())
self.organisation_password=(cur.fetchone())[0]
cur.execute("select port from data where id="+str(self.organisation_id.get()))
self.organisation_port=(cur.fetchone())[0]
cur.execute("select name from data where id="+self.organisation_id.get())
self.organisation_name=(cur.fetchone())[0]
cur.execute("select database_name from data where id="+str(self.organisation_id.get()))
self.organisation_database=(cur.fetchone())[0]
cur.execute("select organisation_password from data where id="+str(self.organisation_id.get()))
self.organisation_log_password=(cur.fetchone())[0]
cur.execute("select version_required from my_persnol_info where id=1")
self.required_version=(cur.fetchone())[0]
cur.execute("select developer_email from my_persnol_info where id=1")
self.developer_email=(cur.fetchone())[0]
con.commit()
con.close()
if self.required_version==self.version:
if str(self.organisation_log_password_var.get()).lstrip()==str(self.organisation_log_password):
self.org_start()
else:
messagebox.showerror("Incorrect","Please enter a correct password.")
else:
messagebox.showerror("UPDATE",f"You are using and older version of application which is {self.version};\nPlease update it to latest version which is {self.required_version};")
except TypeError:
messagebox.showerror("Not Found","Your Organisation was not found")
except:
messagebox.showerror("Error!","Please check you Internet connectivity or\ncontact the Admin of your Organisation.")
except ValueError:
messagebox.showerror("Error!","Please enter valid Organisation ID.")
else:
messagebox.showerror("Must!","All details are must.")
输入框没有输入完整的详细信息,弹出消息框就是这样。
我搜索了我的问题并找到了相同的原因,但找不到解决方案。我附上问题的 及其原因。我只需要解决问题。
在 org_log() 函数末尾添加 return "break" 将解决问题。
这是我家Window的应用。
这是单击“登录”按钮后我的应用程序的Window。
现在,如您所见,按钮没有升起。
我附上了点击按钮后发生的事情的代码片段。
self.org_frame=Frame(self.root,relief=RIDGE,bd=4,bg="#F7DC6F")
self.org_frame.pack()
self.org_lbl=Label(self.org_frame,text="Organisation ID",fg="black",bg="#F7DC6F" ,font=("helvetica","18","bold"))
self.org_lbl.grid(row=0,column=0)
self.txt_org=Entry(self.org_frame,width=12,textvariable=self.organisation_id, font=("times new roman",18,"bold"),bd=5)
self.txt_org.grid(row=0,column=1,pady=10,padx=20)
self.org_lbl=Label(self.org_frame,text="Password",fg="black",bg="#F7DC6F" ,font=("helvetica","18","bold"))
self.org_lbl.grid(row=1,column=0)
self.txt_org=Entry(self.org_frame,width=12,show='•',textvariable=self.organisation_log_password_var, font=("times new roman",18,"bold"),bd=5)
self.txt_org.grid(row=1,column=1,pady=10,padx=20)
self.new_btn=Button(self.org_frame,text="New? Sign Up!",width=12,font=("times new roman",16,"bold"),bd=3,cursor="hand2",bg="orange",command=self.new_def)
self.new_btn.grid(row=2,column=0,padx=10,pady=10)
self.log_btn=Button(self.org_frame,text="Log In",width=10,font=("times new roman",12,"bold"),bd=3,cursor="hand2",bg="lightgreen",fg="green")
self.log_btn.grid(row=2,column=1,padx=10,pady=10)
self.log_btn.bind("<Button-1>",self.org_log)
self.root.bind("<Return>",self.org_log)
def new_def(self):
messagebox.showinfo("New Account!","To create new Organisation kindly mail us your request\nat aakarsh2504@gmail.com.")
def org_log(self,event):
if str(self.organisation_id.get()).lstrip()!="" and str(self.organisation_log_password_var.get()).lstrip()!="":
try:
int(self.organisation_id.get())
try:
con=mysql.connector.connect(host=self.developer_host,user=self.developer_user_id,port=self.developer_port,password=self.developer_password,database=self.developer_database)
cur=con.cursor()
cur.execute("select host from data where id="+self.organisation_id.get())
self.host=(cur.fetchone())[0]
cur.execute("select user from data where id="+str(self.organisation_id.get()))
self.oragnisation_user_id=(cur.fetchone())[0]
cur.execute("select db_password from data where id="+self.organisation_id.get())
self.organisation_password=(cur.fetchone())[0]
cur.execute("select port from data where id="+str(self.organisation_id.get()))
self.organisation_port=(cur.fetchone())[0]
cur.execute("select name from data where id="+self.organisation_id.get())
self.organisation_name=(cur.fetchone())[0]
cur.execute("select database_name from data where id="+str(self.organisation_id.get()))
self.organisation_database=(cur.fetchone())[0]
cur.execute("select organisation_password from data where id="+str(self.organisation_id.get()))
self.organisation_log_password=(cur.fetchone())[0]
cur.execute("select version_required from my_persnol_info where id=1")
self.required_version=(cur.fetchone())[0]
cur.execute("select developer_email from my_persnol_info where id=1")
self.developer_email=(cur.fetchone())[0]
con.commit()
con.close()
if self.required_version==self.version:
if str(self.organisation_log_password_var.get()).lstrip()==str(self.organisation_log_password):
self.org_start()
else:
messagebox.showerror("Incorrect","Please enter a correct password.")
else:
messagebox.showerror("UPDATE",f"You are using and older version of application which is {self.version};\nPlease update it to latest version which is {self.required_version};")
except TypeError:
messagebox.showerror("Not Found","Your Organisation was not found")
except:
messagebox.showerror("Error!","Please check you Internet connectivity or\ncontact the Admin of your Organisation.")
except ValueError:
messagebox.showerror("Error!","Please enter valid Organisation ID.")
else:
messagebox.showerror("Must!","All details are must.")
输入框没有输入完整的详细信息,弹出消息框就是这样。
我搜索了我的问题并找到了相同的原因,但找不到解决方案。我附上问题的
在 org_log() 函数末尾添加 return "break" 将解决问题。