-1

So I have a login script called login.py. When user log in, script will create a user session and execute main.py and close login.py. How to do this?

makifv
  • 27
  • 1
  • 5

2 Answers2

0

I'm a little confused by what you need help with but try this:

from fileName import function_you_want

Ideally you don't want a script to run on an import. It can cause some unexpected things to happen. At the bottom of main.py I would use this:

if __name__ == "__main__":
     call_your_function()

This way you can do tests by running the script directly or calling a specific method from another py file without running the script.

Peter Jones
  • 191
  • 5
0

What you can do is import that file main.py like import main. If you want everything from that file, from main import *

Then, after the user logins, destroy your main window using <Tk>.destroy() and then call your function.