Python 3.4 tkinter button -


my program should destroy btn1 , create again after 1 second in loop. don't no why program destroy btn1 , don't show again. have idea why?

from tkinter import * import random  def hide():     btn1.destroy()     btn1.after(2000,hide)  def show():     btn1 = button(root, bd=c, text="hello\nworld", relief="ridge", cursor="trek")     btn1.grid(row=0,column=0)     btn1.after(3000,show)  root = tk()  root.geometry("350x150+400+400")  c=random.randint(20,40)  btn1 = button(root, bd=c, text="hello\nworld", relief="ridge", cursor="trek") btn1.grid(row=0,column=0)  btn1.after(2000,hide) btn1.after(3000,show)  root.mainloop()  

it work if use grid_forget instead of creating new object each time. note happens @ multiples of 6 seconds (2000 x 3000) depends on 1 last 1 execute.

def hide():     btn1.grid_forget()     btn1.after(2000,hide)  def show():     btn1.grid(row=0,column=0)     btn1.after(3000,show)  root = tk()  root.geometry("350x150+400+400")  c=random.randint(20,40)  btn1 = button(root, bd=c, text="hello\nworld",               relief="ridge", cursor="trek") btn1.grid(row=0,column=0)  btn1.after(2000,hide) btn1.after(3000,show)  root.mainloop() 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -