python-3.x - 窗口没有响应?
问题描述
import tkinter as tk
from tkinter import *
import mysql.connector
from pandas import *
from win32api import GetSystemMetrics
import tkinter.messagebox as box
ride=tk.Tk()
ride.geometry("{}x{}".format(GetSystemMetrics(0),GetSystemMetrics(1)))
frame = Frame(ride)
def ok1():
mySQLconnection = mysql.connector.connect(user="root",passwd="1234",database="reactor1")
cursor = mySQLconnection .cursor()
cursor.execute("select Password from admincredentials")
data1 = DataFrame(cursor.fetchall())
data1.rename(columns={0:'at'},inplace=True)
s=0
s = data1.loc[:,'at'].values
if(s[0]==entry1.get()):
rate=tk.Tk()
rate.title('Change Password')
rate.geometry("{}x{}".format(GetSystemMetrics(0),GetSystemMetrics(1)))
frame = Frame(rate)
def ok():
mydb = mysql.connector.connect(user="root",passwd="1234",database="reactor1")
cursor = mydb.cursor()
cursor.execute("DROP TABLE IF EXISTS admincredentials")
cursor.execute("CREATE TABLE admincredentials (Username varchar(20),Password varchar(20))")
cursor.execute("""INSERT INTO admincredentials (Username,Password) VALUES (%s,%s)""",('admin',entry2.get(),))
mydb.commit()
rate.destroy()
Label(rate,text = 'Enter new password:',bg='white',font='Arial 10 bold').pack(padx=15,pady= 5)
entry2 = Entry(rate,bd =5)
entry2.pack(padx=15, pady=5)
Button(frame,text='ok',command=ok,bg='black',fg='white').pack()
frame.pack(padx=100,pady = 19)
ride.destroy()
rate.mainloop()
else:
box.showinfo('Info','Password does not match. Please enter the correct password')
Label1 = Label(ride,text = 'Enter old password:',bg='white',font='Arial 10 bold') #Text(Username) to be displayed
Label1.pack(padx=15,pady= 5)
entry1 = Entry(ride,bd =5) #Entry box to enter the username
entry1.pack(padx=15, pady=5)
Button(frame,text='ok',command=ok1,bg='black',fg='white').pack()
frame.pack(padx=100,pady = 19)
ride.mainloop()
我想通过检查旧密码来更改密码。它正在检查旧密码并打开下一个窗口输入新密码。但是输入新密码后,我得到窗口没有响应。如果我只单独运行第二部分(新密码),它工作正常。
解决方案
推荐阅读
- julia - Julia:颜色渐变以 0 为中心的热图
- spring - LDAP 自定义 AuthnticationProvider Spring
- python - 如何在PIL中的模板后面粘贴一个小png?
- azure-active-directory - 使用在新租户中创建的 Azure 服务主体时的访问问题
- confluence-rest-api - 使用 Confluence REST API 搜索用户创建的页面
- python - FastAPI - 端点返回枚举值之一
- tbb - 使用oneDPL时如何解决“命名空间'tbb'中没有名为'task'的成员”错误?
- html - CSS | Flexbox - 我的 flexbox 容器位于其他容器之上
- linux - 并行运行 shell 函数的多个实例,而不将输出与其他作业混合
- python - 了解文件路径命名