2016-11-22 21 views
0

私の手では解決できないエラーがあります。私はそれが開かれた後に定義された変数を見つける私は、すべてのウィンドウが開いているわけではないので、私は新しいユーザーの詳細を入力したら、私は新しいユーザーの画面を読み込むとき、私はリダイレクトするボタンを入れボタンを呼び出すことができないと言っているexistingUserEntryページには、何か助けが必要ですか?"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()を使用してください。

  • はあなたが正確に何をしているかわからない場合、あなたが最も可能性の高いmainloop()どこでもを使用したくない(そこだけ1 Tk()このコードではあるが、あなたはあなたの実際のコードでより多くを持っているようにそれは感じている)が、あなたのプログラムの終わりに。

関連する問題