教程 > tkinter 教程 > 阅读:94

tkinter 教程 scale 控件——迹忆客-ag捕鱼王app官网

tkinter scale 控件,用户可以通过移动沿此 scale 控件的滑块按钮从设定范围值选择数值的控件。

你可以指定最小值和最大值以及 scale 的分辨率。与 entry 控件相比,scale 提供有界的数值。


tkinter scale 例子

import tkinter as tk
 
app = tk.tk() 
app.geometry('300x200')
app.title("basic scale")
scaleexample = tk.scale(app, from_=0, to=10)
scaleexample.pack()
app.mainloop()
scaleexample = tk.scale(app, from_=0, to=10)

from_ 指定范围的最小值,to 指定范围的最大值。


tkinter scale 方向和分辨率

import tkinter as tk
 
app = tk.tk() 
app.geometry('300x200')
app.title("tkitner scale example")
scaleexample = tk.scale(app,
                        orient='horizontal',
                        resolution=0.1,
                        from_=0,
                        to=10)
scaleexample.pack()
app.mainloop()

tkinter scale 方向和分辨率

scaleexample = tk.scale(app,
                        orient='horizontal',
                        resolution=0.1,
                        from_=0,
                        to=10)
orient='horizontal'

tkinter scale 的默认方向是竖直的,如第一个示例所示。你需要指定 scaleorient 属性为 horizontal,从而得到一个 tkinter 水平的 scale。

resolution=0.1

可以通过修改 scale 的 resolution 来更改 scale 的分辨率,其默认值为 1。

查看笔记

扫码一下
查看教程更方便
网站地图