1

I have created a GUI using Tkinter. The GUI is supposed to open a file and read the content. However, if the file content is really big and if certain task takes up a lot of time, it would require a loading screen to let user know it is loading.

This loading screen should also get all the focus and not allow user to click on anything else on the GUI until task is complete. How can I do this?

The following is a simple example of my code. It would be great if I can get a modified version of the code back:

from Tkinter import Tk, Frame, BOTH, Menu

class Application(Frame):
   def __init__(self, parent):
      Frame.__init__(self, parent)
      self.parent = parent
      self.parent.geometry('%dx%d+%d+%d' % (800, 300, 0, 0))
      self.parent.resizable(0, 0)

      menubar = Menu(self.parent)
      self.parent.config(menu = menubar)
      self.fileMenu = Menu(menubar, tearoff = 0)
      self.fileMenu.add_command(label = "Open", accelerator = "Ctrl+O", command = self.onOpen)
      menubar.add_cascade(label = "File", menu = self.fileMenu)
      self.pack(fill = BOTH, expand = True)
   def onOpen(self):
      pass

def main():
   root = Tk()
   Application(root)
   root.mainloop()

if __name__ == '__main__':
   main()
6
  • 1
    What, if anything, have you tried so far? Commented Apr 22, 2014 at 17:14
  • I have been doing some reading, and it seems like I can use after(). Just set a flag once loading is complete then clear the loading screen Commented Apr 22, 2014 at 17:34
  • Not sure if anybody has a better solution, and easy to implement Commented Apr 22, 2014 at 17:34
  • This question is a possible duplicate: stackoverflow.com/questions/23215226/… You may also want to monitor it. Commented Apr 22, 2014 at 19:58
  • Are you doing the work in a different thread, or in the same thread the GUI is running in? If it's in the same thread, the best you might hope to do is blit an image on a canvas inside a toplevel. Commented Apr 22, 2014 at 22:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.