0

I have script like this

if int(isValidUser)==1:
            UserNameTB.place_forget()
            PasswordTB.place_forget()

            import MainPage

        else:
            tk.messagebox.showinfo(message="wrong account")

I have window called mainForm so when I run this code it opens windows where are LogIn form. so for example someone Loged in correctly it imports MainPage (mainPage is account window)

the mainPage script is like this:

import LogInPage
import tkinter as tk
menubar=tk.Menu(mainForm)
menubar.add_command(label="Customer",command=ShowCustomerWidgets)
menubar.add_command(label="Operator",command=ShowOperatorWidgets)
menubar.add_command(label="Admin")
mainForm.config(menu=menubar)

So when It runs this script it creates another Window where is still LogIn form and also mainPage widgets, how could I stop this, so for example when user Logs in the window stayed the same but different widgets came up and old ones disappear.

P.S I can't put the whole code in One .py file

4

1 回答 1

0

如果问题是由于LogInPage在导入期间执行...您可以保护 LogInPage 中的代码。阻止这些代码if __name__ == '__main__:被 import 语句执行。

于 2013-08-25T14:58:42.170 回答