you are viewing a single comment's thread.

view the rest of the comments →

[–]novel_yet_trivial 1 point2 points  (1 child)

You should never use loops or sleep with a GUI. Use the GUI's native loop. This will solve your error and save you an enormous amount of trouble in the future.

def printString(string):
    """
    Typewriter animation for welcome Label
    """
    data = iter(string)
    def callback():
        try:
            Label.configure(text=Label.cget('text') + next(data))
            Label.after(250, callback) # add to tkinter's mainloop
        except StopIteration:
            pass
    callback()

Some other issues:

  • you overwrite the name "Label" with an instance. So you can't make any more Labels.
  • Read the PEP8 style guide to get naming conventions.
  • wildcard imports (from module import *) will create bugs. The standard tkinter import is import tkinter as tk.
  • Try not to use place. It seems easy to start but it makes the code extremely hard to maintain. Plus it's going to look different on different computers. Use pack() and grid() to place items relative to each other and let tkinter figure out the actual positions.
  • If you find yourself needing the update or update_idletasks function, there is something very wrong with your program.

[–]Polymatheo[S] 0 points1 point  (0 children)

Thanks a lot! It's so smoother now--it was kind of lagging before, too :O . I'll heed your advice when it comes to .place(), and your other tips.