窗口没有响应?

时间:2019-04-25 05:30:10

标签: python-3.x tkinter

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()

我想通过检查旧密码来更改密码。它正在检查旧密码并打开下一个窗口以输入新密码。但是输入新密码后,我得到的窗口没有响应。如果我仅单独运行第二部分(新密码),则工作正常。

0 个答案:

没有答案