'how do i stop functions in multiple files and functions?

I use 1 Window with switching Frames. Every Frame has its own Layout with Frames, Labels, Buttons etc. I try to put every big function into a seperate file. So I have a main.py, frame1.py , frame2.py, auth.py, mqtt.py and so on.

At the Moment the new Frame lays on top of the Frame before.

Some functions use framex.after(x,function). At my current state i see my programm is getting slower because i think some old and no more needed functions are running.

Do I stop those functions if i close the Frames ? And how do i do that ?

My Code for Frameselection:

def show_frame(frame):
    print('show frame activated with frame : ',frame)
    frame.tkraise()


def window():

  if __name__ == "__main__":  
        print('mainwindow was started directly')
    else:  
        global framea
        framea = frame1(welcome)
        global frameb
        frameb = start.frame2(welcome)
        global framec
        framec = cam1.frame3(welcome)

    #fullscreen frame in window 
    for frame in (framea, frameb, framec ):
        frame.place(relheight = 1, relwidth = 1)
    
    #startframe
    show_frame(framea)

The frames are functions and call them with, for instance,: mw.show_frame(mw.framec)

I am new in Python and i am not familiar with classes.

I would be happy if someone could help me out.

Greetings Chorum



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source