class5_Radiobutton 选择按钮(选项选择)

最终的运行效果图(程序见序号4)

 





#!/usr/bin/env python
# -*- coding:utf-8 -*-
# ------------------------------------------------------------
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# ------------------------------------------------------------
#
# 参考资料:
# 用 python 和 tkinter 做简单的窗口视窗 - 网易云课堂
# http://study.163.com/course/courseLearn.htm?courseId=1003216011#/learn/video?lessonId=1003651316&courseId=1003216011
#
# ------------------------------------------------------------
# ******************** 课时5Radiobutton 选择按钮 *******************
# ******************** 课时5Radiobutton 选择按钮 *******************
# =====>>>>>>内容概览
# =====>>>>>>内容概览

'''
# ------------------------------------------------------------
# # 1、Radiobutton 设定选项
# ------------------------------------------------------------

# ------------------------------------------------------------
# # 2、Radiobutton 设定多个选项
# ------------------------------------------------------------

# ------------------------------------------------------------
# # 3、Radiobutton 设定 多个选项 + 标签
# ------------------------------------------------------------

# ------------------------------------------------------------
# # 3.1、Radiobutton 设定 多个选项 + 标签
# ------------------------------------------------------------

# ------------------------------------------------------------
# # 4、Radiobutton 设定 多个选项 + 标签( 与选项的内容进行关联 )
# ------------------------------------------------------------

'''




# ------------------------------------------------分割线-------------------------------------------------
# ------------------------------------------------分割线-------------------------------------------------
# ------------------------------------------------分割线-------------------------------------------------


'''
# ------------------------------------------------------------
# # 1、Radiobutton 设定选项
# ------------------------------------------------------------
'''
#
# import tkinter as tk
#
# # 设定窗口与尺寸
# window = tk.Tk()
# window.title("My Window")
# window.geometry("200x400")
#
# # 设定选项
# r1 = tk.Radiobutton(window, text= 'Option A')
# r1.pack()
#
# window.mainloop()
# ------------------------------------------------分割线-------------------------------------------------














# ------------------------------------------------分割线-------------------------------------------------
'''
# ------------------------------------------------------------
# # 2、Radiobutton 设定多个选项 
# ------------------------------------------------------------
'''
#
# import tkinter as tk
#
# # 设定窗口与尺寸
# window = tk.Tk()
# window.title("My Window")
# window.geometry("200x400")
#
# # 设定选项
# r1 = tk.Radiobutton(window, text= 'Option A')
# r1.pack()
#
# r2 = tk.Radiobutton(window, text='Option B')
# r2.pack()
#
# r3 = tk.Radiobutton(window, text='Option C')
# r3.pack()
#
# window.mainloop()










# ------------------------------------------------分割线-------------------------------------------------
'''
# ------------------------------------------------------------
# # 3、Radiobutton 设定 多个选项 + 标签 
# ------------------------------------------------------------
'''
#
# import tkinter as tk
#
# # 设定窗口与尺寸
# window = tk.Tk()
# window.title("My Window")
# window.geometry("200x400")
# # 设定标签
# l1 = tk.Label(window, text='Label')
# l1.pack()
#
# # 设定选项
# r1 = tk.Radiobutton(window, text= 'Option A')
# r1.pack()
#
# r2 = tk.Radiobutton(window, text='Option B')
# r2.pack()
#
# r3 = tk.Radiobutton(window, text='Option C')
# r3.pack()
#
# window.mainloop()















# ------------------------------------------------分割线-------------------------------------------------

'''
# ------------------------------------------------------------
# # 3.1、Radiobutton 设定 多个选项 + 标签 
# ------------------------------------------------------------
'''
#
# import tkinter as tk
#
# # 设定窗口与尺寸
# window = tk.Tk()
# window.title("My Window")
# window.geometry("200x400")
#
# # 设定标签
# l1 = tk.Label(window, text='empty', bg='yellow', width=20)
# l1.pack()
#
# # 设定选项
# r1 = tk.Radiobutton(window, text= 'Option A')
# r1.pack()
#
# r2 = tk.Radiobutton(window, text='Option B')
# r2.pack()
#
# r3 = tk.Radiobutton(window, text='Option C')
# r3.pack()
#
# window.mainloop()














'''
# ------------------------------------------------------------
# # 4、Radiobutton 设定 多个选项 + 标签( 与选项的内容进行关联 )
# ------------------------------------------------------------
'''
#
# import tkinter as tk
#
# # ********* 序号3添加的内容 *********
# def print_selection():
#     '''
#     实现 选项与标签的内容进行关联
#     :return:
#     '''
#     global VAR
#     l1.config(text='you have selected '+ VAR.get() )
#
#
# # 设定窗口与尺寸
# window = tk.Tk()
# window.title("My Window")
# window.geometry("200x400")
#
# # ********* 序号3添加的内容 *********
# VAR = tk.StringVar()
#
# # 设定标签
# l1 = tk.Label(window, text='empty', bg='yellow', width=20)
# l1.pack()
#
#
# # ********* 序号3进行了修改 *********
# # 设定选项
# r1 = tk.Radiobutton(window, text= 'Option A', value='A',
#                     variable=VAR, command=print_selection)
# r1.pack()
#
# r2 = tk.Radiobutton(window, text='Option B',value='B',
#                     variable=VAR, command=print_selection )
# r2.pack()
#
# r3 = tk.Radiobutton(window, text='Option C', value='C',
#                     variable=VAR, command=print_selection)
# r3.pack()
#
# window.mainloop()

  


最终的运行效果图(程序见序号4)

 

posted @ 2018-08-29 22:06  JY小脚丫  阅读(563)  评论(0编辑  收藏  举报