[问题] (新手)关于radiobutton

楼主: Arrowrain (Arrow)   2018-06-17 02:03:12
恳求各位大大帮忙
排版如很乱 请见谅
本人python入门
想制作一个查询电影对应哪些电影院的程式
以下是我的程式码
不懂为什么点选哪一个
都只会跑出同一些电影院
然而
tk.Radiobutton(base,text=movie[0],variable = radio_value,value = 0).pack()
如果把这些的base拿掉
可以正常运作
问题在哪呢
import tkinter as tk
base = tk.Tk()
base.title('高雄电影查询程式')
tk.Label(base,bg='gold',width=60,height=2,text='\n 欢迎使用本程式 \n 依您的需求点选需要的服务 \n').pack()
def push():
import tkinter as tk
base = tk.Tk()
radio_value = tk.IntVar()
radio_value.set(1)
movie = {0:'瞒天过海:八面玲珑',1:'侏罗纪世界殒落国度',2:'没关系是渣男啊',3:'操控游戏',4:'拉斐尔艺术之王',5:'烈爱交易',6:'美国罗曼死',7:'死侍2',8:'星际大战外传韩索罗',9:'龙怪客',10:'复仇者联盟3无限之战2',11:'真心话大冒险',12:'紧急呼救211',13:'姐就是美',14:'犬之岛',15:'高压行动',16:'真爱收信中',17:'暴动之城',18:'被爱妄想症',19:'CODE GEASS反叛的鲁路修II叛道 ',20:'波伽利声命之歌'}
tk.Radiobutton(base,text = movie[0],variable = radio_value,value = 0).pack()
tk.Radiobutton(base,text = movie[1],variable = radio_value,value = 1).pack()
tk.Radiobutton(base,text = movie[2],variable = radio_value,value = 2).pack()
tk.Radiobutton(base,text = movie[3],variable = radio_value,value = 3).pack()
tk.Radiobutton(base,text = movie[4],variable = radio_value,value = 4).pack()
tk.Radiobutton(base,text = movie[5],variable = radio_value,value = 5).pack()
tk.Radiobutton(base,text = movie[6],variable = radio_value,value = 6).pack()
tk.Radiobutton(base,text = movie[7],variable = radio_value,value = 7).pack()
tk.Radiobutton(base,text = movie[8],variable = radio_value,value = 8).pack()
tk.Radiobutton(base,text = movie[9],variable = radio_value,value = 9).pack()
tk.Radiobutton(base,text = movie[10],variable = radio_value,value = 10).pack()
tk.Radiobutton(base,text = movie[11],variable = radio_value,value = 11).pack()
tk.Radiobutton(base,text = movie[12],variable = radio_value,value = 12).pack()
tk.Radiobutton(base,text = movie[13],variable = radio_value,value = 13).pack()
tk.Radiobutton(base,text = movie[14],variable = radio_value,value = 14).pack()
tk.Radiobutton(base,text = movie[15],variable = radio_value,value = 15).pack()
tk.Radiobutton(base,text = movie[16],variable = radio_value,value = 16).pack()
tk.Radiobutton(base,text = movie[17],variable = radio_value,value = 17).pack()
tk.Radiobutton(base,text = movie[18],variable = radio_value,value = 18).pack()
tk.Radiobutton(base,text = movie[19],variable = radio_value,value = 19).pack()
tk.Radiobutton(base,text = movie[20],variable = radio_value,value = 20).pack()
def choose():
value = radio_value.get()
if (value == 0):
import tkinter as tk
import tkinter.messagebox as msg
response = msg.showinfo('电影于以下地点拨放','\n 高雄威秀\n 驳二电影院\n 高雄环球数位3D影城\n 国宾义大世界影城\n 喜满客梦时代影城\n 国宾大鲁阁草衙道影城\n 奥斯卡3D数位影城\n MLD影城\n 美奇莱影城\n 三多数位3D影城\n 冈山统一3D数位戏院\n MLD影城\n 奥斯卡3D数位影城\n 冈山统一3D数位戏院\n')
elif (value == 1):
import tkinter as tk
import tkinter.messagebox as msg
response = msg.showinfo('电影于以下地点拨放','\n 高雄威秀\n 驳二电影院\n 高雄环球数位3D影城\n 国宾义大世界影城\n 喜满客梦时代影城\n 国宾大鲁阁草衙道影城\n 奥斯卡3D数位影城\n MLD影城\n 美奇莱影城\n 和春影城\n 十全电影城\n 三多数位3D影城\n 冈山统一3D数位戏院\n 高雄市电影馆\n MLD影城\n 奥斯卡3D数位影城\n 冈山统一3D数位戏院')
elif (value == 4):
import tkinter as tk
import tkinter.messagebox as msg
response = msg.showinfo('电影于以下地点拨放','\n MLD影城')
elif (value == 5):
import tkinter as tk
import tkinter.messagebox as msg
response = msg.showinfo('电影于以下地点拨放','\n MLD影城','奥斯卡3D数位影城')
elif (value == 6):
import tkinter as tk
import tkinter.messagebox as msg
response = msg.showinfo('电影于以下地点拨放','\n 奥斯卡3D数位影城')
elif (value == 7):
import tkinter as tk
import tkinter.messagebox as msg
response = msg.showinfo('电影于以下地点拨放','\n 驳二电影院\n 高雄威秀\n 高雄环球数位3D影城\n 国宾义大世界影城\n 美奇莱影城\n 喜满客梦时代影城\n 国宾大鲁阁草衙道影城\n MLD影城\n 奥斯卡3D数位影城\n 冈山统一3D数位戏院')
elif (value == 8):
import tkinter as tk
import tkinter.messagebox as msg
response = msg.showinfo('电影于以下地点拨放','\n 驳二电影院\n 高雄威秀\n 高雄环球数位3D影城\n 国宾义大世界影城\n 美奇莱影城\n 喜满客梦时代影城\n 国宾大鲁阁草衙道影城\n 三多数位3D影城\n MLD影城\n 奥斯卡3D数位影城\n 冈山统一3D数位戏院')
elif (value == 9):
import tkinter as tk
import tkinter.messagebox as msg
response = msg.showinfo('电影于以下地点拨放','\n 高雄威秀\n 高雄环球数位3D影城\n 国宾义大世界影城\n 美奇莱影城\n 喜满客梦时代影城\n 国宾大鲁阁草衙道影城\n 三多数位3D影城\n MLD影城\n 奥斯卡3D数位影城\n 冈山统一3D数位戏院')
elif (value == 10):
import tkinter as tk
import tkinter.messagebox as msg
response = msg.showinfo('电影于以下地点拨放','\n 高雄威秀\n 国宾义大世界影城\n 喜满客梦时代影城\n 国宾大鲁阁草衙道影城\n 三多数位3D影城\n MLD影城\n 奥斯卡3D数位影城')
elif (value == 11):
import tkinter as tk
import tkinter.messagebox as msg
response = msg.showinfo('电影于以下地点拨放','\n 高雄威秀\n 高雄环球数位3D影城\n 喜满客梦时代影城\n 国宾大鲁阁草衙道影城\n 三多数位3D影城')
elif (value == 12):
import tkinter as tk
import tkinter.messagebox as msg
response = msg.showinfo('电影于以下地点拨放','\n 高雄威秀\n 高雄环球数位3D影城\ n美奇莱影城\n 喜满客梦时代影城\n MLD影城')
elif (value == 13):
import tkinter as tk
import tkinter.messagebox as msg
response = msg.showinfo('电影于以下地点拨放','\n 驳二电影院\n 高雄威秀\n 高雄环球数位3D影城\n 喜满客梦时代影城')
elif (value == 14):
import tkinter as tk
import tkinter.messagebox as msg
response = msg.showinfo('电影于以下地点拨放','\n 驳二电影院\n 高雄威秀\n 美奇莱影城\n MLD影城')
elif (value == 15):
import tkinter as tk
import tkinter.messagebox as msg
response = msg.showinfo('电影于以下地点拨放','\n 高雄威秀\n MLD影城\n 奥斯卡3D数位影城')
elif (value == 16):
import tkinter as tk
import tkinter.messagebox as msg
response = msg.showinfo('电影于以下地点拨放','\n 驳二电影院\n MLD影城')
elif (value == 17):
import tkinter as tk
import tkinter.messagebox as msg
response = msg.showinfo('电影于以下地点拨放','\n 三多数位3D影城\n 奥斯卡3D数位影城')
elif (value == 18):
import tkinter as tk
import tkinter.messagebox as msg
response = msg.showinfo('电影于以下地点拨放','\n 驳二电影院')
elif (value == 20):
import tkinter as tk
import tkinter.messagebox as msg
response = msg.showinfo('电影于以下地点拨放','\n 驳二电影院')
else:
import tkinter as tk
import tkinter.messagebox as msg
response = msg.showinfo('电影于以下地点拨放','\n 高雄威秀')
tk.Button(base, text='选择',command=choose).pack()
button1 = tk.Button(base, text='想看什么电影',command=push,height=5,width=30).pack()
作者: gmccntzx1 (o.O)   2018-06-17 02:14:00
先把程式码贴到 codepad/ideone/gist/... 上面
作者: chliu6 (反正我就是烂)   2018-06-17 08:53:00
在Push()中,要用base=tk.Toplevel()

Links booklink

Contact Us: admin [ a t ] ucptt.com