Pyhon
1import sys 2import tkinter 3 4root = tkinter.Tk() 5root.title(u"test") 6root.geometry("800x450") 7 8def test1(): 9 Button1.destroy() 10 Button2.place(x=130, y=300) 11def test2(): 12 Button2.destroy() 13 Button1.place(x=130, y=200) 14 15Button1 = tkinter.Button(text=u'1', fg='black', bg='aqua', width=40, command=test1) 16Button2 = tkinter.Button(text=u'2', fg='black', bg='aqua', width=40, command=test2) 17 18Button1.place(x=130, y=200) 19 20 21root.mainloop()
目標
ボタン1を押すとボタン2が表れてボタン1が消える。
ボタン2を押すとボタン1が表れてボタン2が消える。
これを繰り返し行えれるようにする。
エラー内容
ボタン2を押すと
_tkinter.TclError: bad window path name ".!button"
このようなエラーが出る。
教えてほしいこと
一度消したボタンをもう一度表示させる方法
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/07/13 07:55