|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
answer[0]有5个值,answer[1]有6个值,answer[1]只显示了5个,没有完全显示出来,怎么办
- from tkinter import *
- x = 0
- root = Tk()
- answers = {0: [('草莓', 2), ('苹果', 3), ('西瓜', 5), ('菠萝', 10), ('橘子', 15)],
- 1: [('郊外', 2), ('电影院', 3), ('公园', 5), ('商场', 10), ('酒吧', 15), ('练歌房', 20)]}
- v = StringVar()
- choices = [] # 保存 Radiobutton 的一个列表
- for ans, point in answers[x]:
- choices1 = Radiobutton(root, text=ans, variable=v, value=point, padx=100, justify='left')
- choices1.pack()
- choices.append(choices1)
- def point_plus_change():
- global x
- x += 1
- x %= 2 # 对 2 求余数
- if x <= 14:
- if x == 0:
- for (ans, point), choices1 in zip(answers[0], choices):
- choices1.config(text=ans, variable=v, value=point, padx=100, justify='left')
- if x == 1:
- for (ans, point), choices1 in zip(answers[1], choices):
- choices1.config(text=ans, variable=v, value=point, padx=100, justify='left')
- butt_addpoint = Button(root, text='确定', font=('黑体', 10), command=point_plus_change)
- butt_addpoint.pack()
- root.mainloop()
复制代码
貌似只能这样……
- from tkinter import *
- x = 0
- root = Tk()
- answers = {0: [('草莓', 2), ('苹果', 3), ('西瓜', 5), ('菠萝', 10), ('橘子', 15), ('', 20)],
- 1: [('郊外', 2), ('电影院', 3), ('公园', 5), ('商场', 10), ('酒吧', 15), ('练歌房', 20)]}
- v = StringVar()
- choices = [] # 保存 Radiobutton 的一个列表
- for ans, point in answers[x]:
- choices1 = Radiobutton(root, text=ans, variable=v, value=point, padx=100, justify='left')
- choices1.pack()
- choices.append(choices1)
- def point_plus_change():
- global x
- x += 1
- x %= 2 # 对 2 求余数
- if x <= 14:
- if x == 0:
- for (ans, point), choices1 in zip(answers[0], choices):
- choices1.config(text=ans, variable=v, value=point, padx=100, justify='left')
- if x == 1:
- for (ans, point), choices1 in zip(answers[1], choices):
- choices1.config(text=ans, variable=v, value=point, padx=100, justify='left')
- butt_addpoint = Button(root, text='确定', font=('黑体', 10), command=point_plus_change)
- butt_addpoint.pack()
- root.mainloop()
复制代码
|
|