Tkinterで「テーブル」を作成しましたが、OptionMenuにリンクされた別の関数として、選択に応じて追加/削除する必要がある別のフレームを作成しました。私のコードは次のとおりです。
def ChoiceBox(choice):
choice_frame = Frame(win1, bg='black')
choice_frame.grid(row=2, column=1, sticky="ew", padx=1, pady=1)
column = 0
if choice == "Fixed":
choice_frame.grid_forget()
tkMessageBox.showinfo("Message", "Fixed.")
elif choice == "List":
i = [0, 1, 2, 3]
for i in i:
choice_title = Label(choice_frame, text='Value %g'% float(i+1), bg='white', borderwidth=0, width=0)
choice_title.grid(row=0, column=column+i, sticky="nsew", padx=1, pady=1)
box = Entry(choice_frame, bg='white', borderwidth=0, width=0)
box.grid(row=1, column=column+i, sticky="ew", padx=1, pady=1)
elif choice == "Between" or "Bigger":
i = [0, 1]
choice_title1 = Label(choice_frame, text='Min Value', bg='white', borderwidth=0, width=0)
choice_title1.grid(row=0, column=column, sticky="nsew", padx=1, pady=1)
choice_title2 = Label(choice_frame, text='Max Value', bg='white', borderwidth=0, width=0)
choice_title2.grid(row=0, column=column+1, sticky="nsew", padx=1, pady=1)
for i in i:
box = Entry(choice_frame, bg='white', borderwidth=0, width=0)
box.grid(row=1, column=column+i, sticky="nsew", padx=1, pady=1)
現在、2つの別々のテーブルを取得していますが、choice_frame'table'は他のテーブルと同じサイズではありません。したがって、このテーブルを最初のテーブルのフレームの一部にしたい(そして、どういうわけかこのセクションだけを削除できるようにしたい)。これは、すでに作業を行っている。もう1つのフレームはframe_table(元のテーブルを作成したフレーム)であり、このフレームと結合したいと考えています。
それ以外の場合は、別のテーブルのように保持したいのですが、[固定]を選択しても表示されなくなります。このコードは、純粋に私が以前に作成したOptionMenuのコマンドです。私が与えられたどんな助けでも大いに感謝します!ありがとうございました。
更新:選択に応じて、行ごとに個別のフレームを取得する必要があります(下の画像を参照)。私はこれに非常に苦労しています!