码迷,mamicode.com
首页 > 其他好文 > 详细

class6_scale尺度

时间:2018-08-30 14:25:01      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:style   --   int   return   资料   win   nta   pack   res   

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

技术分享图片

 

 

 

 


#!/usr/bin/env python
# -*- coding:utf-8 -*-
# ------------------------------------------------------------
#
# 参考资料:
# Python2 Tutorial: Sliders in Tkinter
# https://www.python-course.eu/tkinter_sliders.php
#
# 用 python 和 tkinter 做简单的窗口视窗 - 网易云课堂
# https://study.163.com/course/courseLearn.htm?courseId=1003216011#/learn/video?lessonId=1003652328&courseId=1003216011
#
#
# ------------------------------------------------------------
# ******************** class6_scale尺度 *******************
# ******************** class6_scale尺度 *******************
# class6_scale尺度
# =====>>>>>>内容概览
# =====>>>>>>内容概览

‘‘‘
# ------------------------------------------------------------
# # 1、Scale的创建与设置
# ------------------------------------------------------------

# ------------------------------------------------------------
# # 2、把尺子的内容显示在窗口中
# ------------------------------------------------------------

# # ------------------------------------------------------------
# # 3、设置初始化尺子的位置
# # # 如: w1.set(19) ==>尺子w1的默认位置是19
# # ------------------------------------------------------------

# ------------------------------------------------------------
# # 3.1、设置初始化尺子的间隔
# # 如: w1 = tk.Scale(window, from_=0, to=50, tickinterval=10)
# # # ==>> tickinterval=10 表标间隔10
# ------------------------------------------------------------

# ------------------------------------------------------------
# # 4、设置初始化尺子的长度
# # # 如: w2 = tk.Scale(window, from_=0, to=200, tickinterval=50, length=200, orient=tk.HORIZONTAL )
# ------------------------------------------------------------

# ------------------------------------------------------------
# # 5、显示尺子
# # 如: s2 = tk.Scale(window, from_=10, to=50, label=‘try me‘, length=200,
# showvalue=True, tickinterval=10, orient=tk.HORIZONTAL,
# resolution=0.01)
# ------------------------------------------------------------

# ------------------------------------------------------------
# # 6、显示尺子 + 标签
# # 如: s2 = tk.Scale(window, from_=10, to=50, label=‘try me‘, length=200,
# showvalue=True, tickinterval=10, orient=tk.HORIZONTAL,
# resolution=0.01)
# ------------------------------------------------------------

# ------------------------------------------------------------
# # 7、显示尺子 + 标签(显示尺子的内容)
# # 如: s2 = tk.Scale(window, from_=10, to=50, label=‘try me‘, length=200,
# showvalue=True, tickinterval=10, orient=tk.HORIZONTAL,
# resolution=0.01)
# ------------------------------------------------------------

‘‘‘


 

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


 

 

‘‘‘
# ------------------------------------------------------------
# # 1、Scale的创建与设置
# ------------------------------------------------------------
‘‘‘
# import tkinter as tk
#
# # 窗口创建与设置
# window = tk.Tk()
# window.title(‘Scale‘)
# window.geometry(‘300x400‘)
#
# # 设置尺子
# w1 = tk.Scale(window, from_=0, to=50)     #  默认是竖直方向
# w1.pack()
#
# w2 = tk.Scale(window, from_=0, to=200, orient=tk.HORIZONTAL)
# w2.pack()
#
# tk.mainloop()
#






# ------------------------------------------------分割线-------------------------------------------------
‘‘‘
# ------------------------------------------------------------
# # 2、把尺子的内容显示在窗口中
# ------------------------------------------------------------
‘‘‘
# import tkinter as tk
#
# def show_value():
#     ‘‘‘
#     用来显示水平数值尺子的内容
#     :return:
#     ‘‘‘
#     print("竖直:%s" %w1.get(), "水平:%s" %w2.get() )
#
# # 窗口创建与设置
# window = tk.Tk()
# window.title(‘Scale‘)
# window.geometry(‘300x400‘)
#
# # 设置尺子
# w1 = tk.Scale(window, from_=0, to=50)
# w1.pack()
#
# w2 = tk.Scale(window, from_=0, to=200, orient=tk.HORIZONTAL)
# w2.pack()
#
# b1 = tk.Button(window, text=‘Show‘, command=show_value)
# b1.pack()
#
#
# tk.mainloop()










#
# # ------------------------------------------------分割线-------------------------------------------------
# ‘‘‘
# # ------------------------------------------------------------
# # # 3、设置初始化尺子的位置
# # # 如: w1.set(19) ==>尺子w1的默认位置是19
# # ------------------------------------------------------------
# ‘‘‘
# import tkinter as tk
#
# def show_value():
#     ‘‘‘
#     用来显示水平数值尺子的内容
#     :return:
#     ‘‘‘
#     print("竖直:%s" %w1.get(), "水平:%s" %w2.get() )
#
# # 窗口创建与设置
# window = tk.Tk()
# window.title(‘Scale‘)
# window.geometry(‘300x400‘)
#
# # 设置尺子
# w1 = tk.Scale(window, from_=0, to=50)
# w1.set(19)
# w1.pack()
#
# w2 = tk.Scale(window, from_=0, to=200, orient=tk.HORIZONTAL)
# w2.set(50)
# w2.pack()
#
# b1 = tk.Button(window, text=‘Show‘, command=show_value)
# b1.pack()
#
# tk.mainloop()












# ------------------------------------------------分割线-------------------------------------------------
‘‘‘
# ------------------------------------------------------------
# # 3、设置初始化尺子的间隔
# # 如: w1 = tk.Scale(window, from_=0, to=50, tickinterval=10)  
        ==>>  tickinterval=10 表标间隔10  
# ------------------------------------------------------------
‘‘‘
# import tkinter as tk
#
# def show_value():
#     ‘‘‘
#     用来显示水平数值尺子的内容
#     :return:
#     ‘‘‘
#     print("竖直:%s" %w1.get(), "水平:%s" %w2.get() )
#
# # 窗口创建与设置
# window = tk.Tk()
# window.title(‘Scale‘)
# window.geometry(‘300x400‘)
#
# # 设置尺子
# w1 = tk.Scale(window, from_=0, to=50, tickinterval=10)
# w1.set(19)
# w1.pack()
#
# w2 = tk.Scale(window, from_=0, to=200, orient=tk.HORIZONTAL, tickinterval=50 )
# w2.set(50)
# w2.pack()
#
# b1 = tk.Button(window, text=‘Show‘, command=show_value)
# b1.pack()
#
# tk.mainloop()
#












# ------------------------------------------------分割线-------------------------------------------------
‘‘‘
# ------------------------------------------------------------
# # 4、设置初始化尺子的长度
# # 如: w2 = tk.Scale(window, from_=0, to=200, tickinterval=50, length=200, orient=tk.HORIZONTAL )  
==>>  length=200  表标长度是200   
# ------------------------------------------------------------
‘‘‘
# import tkinter as tk
#
# def show_value():
#     ‘‘‘
#     用来显示水平数值尺子的内容
#     :return:
#     ‘‘‘
#     print("竖直:%s" %w1.get(), "水平:%s" %w2.get() )
#
# # 窗口创建与设置
# window = tk.Tk()
# window.title(‘Scale‘)
# window.geometry(‘300x400‘)
#
# # 设置尺子
# w1 = tk.Scale(window, from_=0, to=50, tickinterval=10)
# w1.set(19)
# w1.pack()
#
# w2 = tk.Scale(window, from_=0, to=200, tickinterval=50, length=200, orient=tk.HORIZONTAL )
# w2.set(50)
# w2.pack()
#
# b1 = tk.Button(window, text=‘Show‘, command=show_value)
# b1.pack()
#
# tk.mainloop()















# ------------------------------------------------分割线-------------------------------------------------
‘‘‘
# ------------------------------------------------------------
# # 5、显示尺子
# # 如: s2 = tk.Scale(window, from_=10, to=50, label=‘try me‘, length=200,
#              showvalue=True, tickinterval=10, orient=tk.HORIZONTAL,
#               resolution=0.01)
label=‘try me‘ :    尺子的标签

showvalue=True:     Ture表示在尺子旁边显示尺子所在位置的数值
tickinterval=10      尺子的间隔的记号     
orient=tk.HORIZONTAL: 方向是水平
resolution=0.01      分辨率是0.01
# ------------------------------------------------------------
‘‘‘
#
# import tkinter as tk
#
# window = tk.Tk()
# window.title("Scale")
# window.geometry("300x500")
#
# s1 = tk.Scale(window, from_=10, to=50, label=‘try me‘, length=200,
#              showvalue=False, tickinterval=10)
# s1.pack()
#
# s2 = tk.Scale(window, from_=10, to=50, label=‘try me‘, length=200,
#              showvalue=True, tickinterval=10, orient=tk.HORIZONTAL,
#               resolution=0.01)
# s2.pack()
#
# tk.mainloop()
#
#
#
#
#
#














# ------------------------------------------------分割线-------------------------------------------------
‘‘‘
# ------------------------------------------------------------
# # 6、显示尺子 + 标签
# # 如: s2 = tk.Scale(window, from_=10, to=50, label=‘try me‘, length=200,
#              showvalue=True, tickinterval=10, orient=tk.HORIZONTAL,
#               resolution=0.01)
label=‘try me‘ :    尺子的标签

showvalue=True:     Ture表示在尺子旁边显示尺子所在位置的数值
tickinterval=10      尺子的间隔的记号     
orient=tk.HORIZONTAL: 方向是水平
resolution=0.01      分辨率是0.01
# ------------------------------------------------------------
‘‘‘
#
# import tkinter as tk
#
# window = tk.Tk()
# window.title("Scale")
# window.geometry("300x500")
#
# # 标签
# l1 = tk.Label(window, bg=‘yellow‘, width=25, text="empty")
# l1.pack()
#
# l2 = tk.Label(window, bg=‘blue‘, width=50, text="empty")
# l2.pack()
#
#
# # 尺子
# s1 = tk.Scale(window, from_=10, to=50, label=‘try me‘, length=200,
#              showvalue=False, tickinterval=10)
# s1.pack()
#
# s2 = tk.Scale(window, from_=10, to=50, label=‘try me‘, length=200,
#              showvalue=True, tickinterval=10, orient=tk.HORIZONTAL,
#               resolution=0.01)
# s2.pack()
#
#
# tk.mainloop()
#


















# ------------------------------------------------分割线-------------------------------------------------
‘‘‘
# ------------------------------------------------------------
# # 7、显示尺子 + 标签(显示尺子的内容)
# # 如: s2 = tk.Scale(window, from_=10, to=50, label=‘try me‘, length=200,
#              showvalue=True, tickinterval=10, orient=tk.HORIZONTAL,
#               resolution=0.01)
label=‘try me‘ :    尺子的标签

showvalue=True:     Ture表示在尺子旁边显示尺子所在位置的数值
tickinterval=10      尺子的间隔的记号     
orient=tk.HORIZONTAL: 方向是水平
resolution=0.01      分辨率是0.01
# ------------------------------------------------------------
‘‘‘
#
# import tkinter as tk
#
# def print_selection1(value):
#     global l1
#     l1.config(text="value: " +value)
#
# def print_selection2(value):
#     global l2
#     l2.config(text="value: " +value)
#
# window = tk.Tk()
# window.title("Scale")
# window.geometry("300x500")
#
# # 标签
# l1 = tk.Label(window, bg=‘yellow‘, width=25, text="empty")
# l1.pack()
#
# l2 = tk.Label(window, bg=‘blue‘, width=50, text="empty")
# l2.pack()
#
#
# # 尺子
# s1 = tk.Scale(window, from_=10, to=50, label=‘try me‘, length=200,
#              showvalue=False, tickinterval=10, command=print_selection1)
# s1.pack()
#
# s2 = tk.Scale(window, from_=10, to=50, label=‘try me‘, length=200,
#              showvalue=True, tickinterval=10, orient=tk.HORIZONTAL,
#               resolution=0.01, command=print_selection2)
# s2.pack()
#
#
# tk.mainloop()

  

  

 

 

 


 

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

技术分享图片

class6_scale尺度

标签:style   --   int   return   资料   win   nta   pack   res   

原文地址:https://www.cnblogs.com/jyfootprint/p/9559669.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!