0

I am writing a GUI with the screen of Raspberry.Each time I destroy a GUI and call a new GUI there will be a delay of about a few seconds to make the user see the raspberry's desktop. I want to draw a loading interface down to the background so that when I switch the screen the user won't see the raspberry desktop. I use this code:

from tkinter import *

class Load_Screen:

    def __init__(self, master):
        self.master = master
        self.master.configure(background='white')
        self.frame = Frame(self.master)
        self.frame.pack()

        self.canvas = Canvas(self.frame, width = 350, height = 250)
        self.canvas.configure(background='white')
        self.canvas.pack()

        self.img = PhotoImage(file="image/loading.png")
        self.canvas.create_image(55,150, anchor=W, image=self.img)

        newWindow = Toplevel(self.master)
        newWindow.geometry("700x500")
        app = Main_Screen(newWindow)

class Main_Screen:

    def __init__(self, master):
        self.master = master
        self.frame = Frame(self.master)
        self.frame.pack()

def main(): 
    root = Tk()
    root.geometry("760x600")
    app = Load_Screen(root)

    root.mainloop()

if __name__ == '__main__':
    main()

However, the loading screen overrides the main screen. And I want the opposite, the bottom loading screen and the main screen above

Pythoner
  • 127
  • 12
  • 2
    don't destroy GUI - replace items in the same window. You can use `Frame` to create screens and replace them in main window `Tk` – furas May 13 '19 at 04:18
  • Thanks. I will do this when I can make the Tk window display override the Toplevel window – Pythoner May 13 '19 at 04:22
  • 1
    replacing `Frame` in window it will always hide desktop and you will no need `Toplevel` window. – furas May 13 '19 at 04:32
  • [How to make a Tkinter window jump to the front?](https://stackoverflow.com/questions/1892339/how-to-make-a-tkinter-window-jump-to-the-front) – furas May 13 '19 at 04:38

1 Answers1

1

This is my solution which i have found at How to make a Tkinter window jump to the front?

from tkinter import *

class Load_Screen:

    def __init__(self, master):
        self.master = master
        self.master.configure(background='white')
        self.frame = Frame(self.master)
        self.frame.pack()

        self.canvas = Canvas(self.frame, width = 350, height = 250)
        self.canvas.configure(background='white')
        self.canvas.pack()

        self.img = PhotoImage(file="image/loading.png")
        self.canvas.create_image(55,150, anchor=W, image=self.img)

        newWindow = Toplevel(self.master)
        newWindow.geometry("700x500")
        app = Main_Screen(newWindow)

class Main_Screen:

    def __init__(self, master):
        self.master = master
        self.frame = Frame(self.master)
        self.frame.pack()

def main(): 
    root = Tk()
    root.geometry("760x600")
    root.lift()
    app = Load_Screen(root)

    root.mainloop()

if __name__ == '__main__':
    main()

Use root.lift() make Load_Screen below Main_Screen

Pythoner
  • 127
  • 12