python使用tkinter可以在多个操作系统_在tkinter GUI中使用多个窗口
我正在用python構建一個非常基礎的電影推薦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()
C1 = Radiobutton(master, text = "Action", variable = CheckVar1, value=1)
C1.pack(side=TOP, padx=10, pady=10)
C2 = Radiobutton(master, text = "Comedy", variable = CheckVar1, value=2)
C2.pack(side=TOP, padx=10, pady=10)
C3 = Radiobutton(master, text = "Documentary", variable = CheckVar1, value=3)
C3.pack(side=TOP, padx=10, pady=10)
C4 = Radiobutton(master, text = "Horror", variable = CheckVar1, value=4)
C4.pack(side=TOP, padx=10, pady=10)
C5 = Radiobutton(master, text = "Romance", variable = CheckVar1, value=5)
C5.pack(side=TOP, padx=10, pady=10)
self.nextbutton = Button(master, text="Next", command=self.reco)
self.nextbutton.pack(side=BOTTOM, padx=10, pady=10)
def reco(self):
self.newWindow = Toplevel(self.master)
self.app = movie2(self.newWindow)
class movie2:
def __init__(self, master):
self.master = master
self.frame = Frame(self.master)
def C1(self):
print("option 1")
root = Tk()
my_gui = movie1(root)
root.mainloop()
總結
以上是生活随笔為你收集整理的python使用tkinter可以在多个操作系统_在tkinter GUI中使用多个窗口的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql 常规命令操作_mysql数据
- 下一篇: vsftp mysql_vsftp my