Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to switch frames multiple times without blackscreening in tkinter?

def SignUp():
  base.destroy()
  import signup
def Signin():
  base.destroy()
  import main

Using this code allows me to switch between frames twice but then it stops working if I try to switch back and forth between frames.
What is the problem?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The import statement only "works" the first time it is executed.

It sounds like you have some modules with code in it which is executed when imported.

You should change your modules to have that code all in functions which can be called on demand.

You could change your code to something like this:

import signup
import main

def SignUp():
  base.destroy()
  signup.main()

def Signin():
  base.destroy()
  main.main()

Obviously you will need to have some functions called def main(): inside both modules.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading