我的代码出了什么问题,我一直想弄清楚几个小时?

时间:2017-11-12 07:23:39

标签: python tkinter

我的节目意味着“获得授权”和“#39;如果我输入正确的用户名和密码,无论我输入什么,我都会收到“登录无效”信息。谁能指出什么是错的?顺便说一句,不要担心缩进是错误的,它会在代码放在这个网站上时发生变化。

from tkinter import *# Ingress all components from Tkinter
import tkinter.messagebox as box

def dialog1():

    username=entry1.get()
    password = entry2.get()
    if (username == 'admin' and  password == 'ad121'):#Correct log in details
        box.showinfo('info','Access granted')# correct response
    else:
        box.showinfo('info','Invalid Login')# decline response

def condition():
     while condition == (username == 'admin' and  password == 'ad121'): 
      print = label(text('Welcome back admin user!',bg='Light Blue',font='none 14 bold').place(x=0,y=160))


window = Tk()
window.geometry('400x400')# The size of the form window
window.title('Office login system')#title of the form

frame = Frame(window)

mlabel = Label(text='Log in system', bg='Light Blue',font='none 18 bold underline')# The colours and font style and size used for the form title
mlabel.pack()

Label1 = Label(window,text = 'Username:',bg='Light Blue',font='none 14 bold').place(x=0,y=100)
entry2 = Entry(window).place(x=140,y=108)#Size and colour of the text box


entry1 = Entry(window,bd =5)
entry1.pack

Label2 = Label(window,text = 'Password:',bg='Light Blue',font='none 14 bold').place(x=0,y=150)
entry2 = Entry(window).place(x=140,y=155)#Size and colour of the text box


entry2 = Entry(window, bd=5)
entry2.pack


window.configure(background='Orange')

btn = Button(window, text = 'Check Login',command = dialog1)


btn.place(x=150,y=250)
frame.pack(padx =200,pady =190)


window.mainloop()# The code iterates 

1 个答案:

答案 0 :(得分:1)

您在脚本范围内多次声明year

我试过这个并且它按预期工作。

if