Python Tkinter: loading screen

我们两清 提交于 2019-12-23 03:23:10

问题


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()

来源:https://stackoverflow.com/questions/23226048/python-tkinter-loading-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!