With three while loop and realize a display tkinter
Import Tkinter AS tk Import Time # input box is a way of dealing with the program, such as program asks you to enter the account password, then it is necessary to provide two input boxes for you. INPUT = str_2 ( ' Enter: ' ) # Enter the content they want the root = tk.Tk () root.geometry ( ' 300x50 ' ) # size to a width of 300 graphical interface high 50 text_1 = tk.Text (the root , font = ( ' Founder italics ' , 12 is, ' Bold ' ), BG = ' Black ' , FG = ' Red ' , width = 33 is ) text_1.grid (Row = 0) the whileTrue: str_1 = str_2 I = 0 # if two cycles are completed, then sleep for 3 seconds, then operation continues at the while True: # If the display elements (characters, English, numbers) number exceeds 16, so long need to be updated, first of all first # delete all the elements, and refresh, then insert the fifteen elements in the display, and then add an element # If the latter element has been less than 16 elements will be inserted in all the remaining elements It can be. IF I == 16 : str_1 = str_1 [. 1 :] text_1.delete ( " 1.0 " , tk.END) root.update I = 15 IF len (str_1)> 16 : for K inRange (15 ): text_1.insert (tk.INSERT, str_1 [K]) the else : for K in Range (len (str_1)): text_1.insert (tk.INSERT, str_1 [K]) the try : text_1.insert ( tk.INSERT, str_1 [I]) the time.sleep ( 0.4 ) I + =. 1 root.update () the except : # the remaining element exhibits a dynamic effect the while True: IF len (str_1) == 0: BREAK # exit innermost loop str_1 = str_1 [1:] Text_1.delete ( " 1.0 " , tk.END) root.update () for JK in Range (len (str_1)): text_1.insert (tk.INSERT, str_1 [JK]) root.update () Time. SLEEP ( 0.4 ) BREAK # exit times a loop inside the time.sleep ( . 3 ) root.mainloop ()
operation result: