'Widgets appearing late

So I'm building this program

def buffer():
    global buf
    frame2 = ttk.Frame(notebk, relief = RAISED)
    if buf==0:
        notebk.add(frame2, text = 'Buffer pH')
        notebk.select(frame2)
        buf=1
    else:
        notebk.select(frame2)
    import buffer
    buffer.main(frame2)

This part of the code is supposed to call another program I've written somewhere in a separate file on a new tab.

def main(x):  
    g=x
    op=Label(g,text="Hello") #...and so on

The program works but the widgets on the new tab appear either significantly late or after the window is configured in some way (moved/resized).

Any tips on how I can fix this?



Sources

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

Source: Stack Overflow

Solution Source