2016-11-22 1 views
0

내 손으로 수정할 수없는 오류가 있습니다. 내가 정의 된 변수를 찾은 후에 페이지가 닫히기를 원합니다. 모든 창이 열리지는 않습니다. 그러나 새 사용자 화면에 새로운 사용자 정보를 입력하면로드합니다. 버튼을 넣으면 리디렉션됩니다. 버튼을 호출 할 수 없다는 기존의 UserEntry 페이지로 어떤 도움이 필요합니까?"button"명령을 호출 할 수 없습니다. 응용 프로그램이 손상되었습니다.

def existingUserEntry(): 
    intitialScreen.destroy() 
    login = False 
    global existingUserScreen, usernameEntry, passwordEntry 
    existingUserScreen = Tk() # Set up a screen 
    existingUserScreen.title("Existing User Login Screen")# Set a caption 
    existingUserScreen.config(bg = "WHITE")# Set the background colour 
    existingUserScreen.geometry("350x150")# Set the size of the window 
    # Code for the username entry box.  
    usernameLabel = Label(existingUserScreen, text = "User name:")# Username Text box 
    usernameLabel.config(bg = "PALE GREEN", font=('Helvetica', 12))# Formatting Features 
    usernameLabel.pack() 
    usernameEntry = ttk.Entry(existingUserScreen, font = "bold", width = 30) 
    usernameEntry.pack() 
    # Code for the password entry box. 
    passwordLabel = Label(existingUserScreen, text = "Password:")# Password Text box 
    passwordLabel.config(bg = "PALE GREEN", font=('Helvetica', 12))# Formatting Features 
    passwordLabel.pack() 
    passwordEntry = ttk.Entry(existingUserScreen, font = "bold", width = 30, show="*") 
    passwordEntry.pack() 
    # Code for the sign in button. 
    signInButton = Button(existingUserScreen, text="Sign in", width=10, command=verifyLoginDetails) 
    signInButton.pack(expand = 1)# Placement of the Sign In button 
    existingUserScreen.mainloop() 

#Code for a button to allow new users to login to profile after creating one 
    newUserSignInButton = Button(newUserScreen, text=" Back to Login Screen", width=15, command=backToLoginScreen) 
    newUserSignInButton.config(height= 1, width= 40) 
    newUserSignInButton.pack(expand= 4) 
    newUserScreen.mainloop() 
    newUserScreen = Button(intitialScreen, text="Existing User Sign In", width=25, command=existingUserEntry) 

답변

1
def existingUserEntry(): 
    intitialScreen.destroy() 
    .... 
    newUserScreen = Button(intitialScreen,...) 

그런 다음 오류가 발생 끝에 해당 컨테이너에 단추를 추가하려고 당신의 방법의 시작 부분에 당신의 intitialScreen을 파괴하고 있습니다. 위젯 용으로 기존 것을 선택해야합니다. 또한

  • 여러 Tk() 인스턴스를 생성하지 마십시오 점에 유의하시기 바랍니다. 다른 창 (예 : 팝업)을 원할 경우 Tk() 대신 Toplevel()을 사용하십시오. 이 코드에는 Tk()이 하나만 있지만 실제 코드가 더 많다고 느껴집니다.

  • 정확히 무엇을하고 있는지 잘 모르는 경우 대체로 mainloop()을 사용하지 않으려 고합니다. 귀하의 프로그램이 끝날 때.

관련 문제