前提
tkinterを用いてtkinter.TopLevel()で作成したサブウィンドウにテキストボックスを配置したいのですが、配置先がメインウィンドウに描画されてしまいます。
(sub_winのtextbox1がメインウィンドウに描画される)
初心者ですのでどこか凡ミスかもしれませんがご教授お願いいたします。
python
1main.py 2import tkinter as tk 3import define as df 4 5root = tk.Tk() 6root.title("test") 7root.geometry("720x480") 8 9button2 = tk.Button(text="ボタン",width=10) 10button2.place(x=278,y=49) 11button2.bind("<Button-1>",df.Sales) 12 13 14define.py 15import tkinter as tk 16 17def Sales(event): 18 # サブウィンドウ 19 global sub_win 20 if sub_win == None or not sub_win.winfo_exists(): 21 sub_win = tk.Toplevel() 22 sub_win.title("サブウィンドウ") 23 sub_win.geometry("480x240") 24 textbox1 = tk.Entry(); 25 textbox1.configure(state="normal",width=20) 26 textbox1.place(x=50,y=20)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。