0
tkinterを使用してムービーの推奨GUIを作成しています。ユーザーがラジオボタンを選択すると、ラジオボタンが選択された新しいウィンドウで開きます。だから誰かがコメディーを選んだら、私は別の映画でコーディングして、新しいウィンドウでランダムにポップアップさせることができます。私はウィンドウを開くためのコマンドを用意していますが、選択した選択肢を呼び戻すのに問題があります。新しいウィンドウでのラジオボタンの選択
from tkinter import *
class movie1:
def __init__(self, master):
self.master = master
master.title("Movie Recommendation")
self.label = Label(master, text= "Welcome to the movie recommendation application! \n Please select the genre of the movie you would like to see.")
self.label.pack(padx=25, pady=25)
CheckVar1 = StringVar()
self.radiobutton = Radiobutton(master, text = "Action", variable=CheckVar1, value=1, command=self.reco)
self.radiobutton.pack(side=TOP, padx=10, pady=10)
self.radiobutton = Radiobutton(master, text = "Comedy", variable=CheckVar1, value=2, command=self.reco)
self.radiobutton.pack(side=TOP, padx=10, pady=10)
self.radiobutton = Radiobutton(master, text = "Documentary", variable=CheckVar1, value=3, command=self.reco)
self.radiobutton.pack(side=TOP, padx=10, pady=10)
self.radiobutton = Radiobutton(master, text = "Horror", variable=CheckVar1, value=4, command=self.reco)
self.radiobutton.pack(side=TOP, padx=10, pady=10)
self.radiobutton = Radiobutton(master, text = "Romance", variable=CheckVar1, value=5, command=self.reco)
self.radiobutton.pack(side=TOP, padx=10, pady=10)
self.radiobutton.cget("value")
def reco(self):
self.newWindow = Toplevel(self.master)
if ("value") == 1:
print("1")
root = Tk()
my_gui = movie1(root)
root.mainloop()
Radiobuttonを確認した例http://www.tutorialsp.com/jp/python/tk_radiobutton.htm –