Tkinter チュートリアル - スケール
Jinku Hu
2023年1月30日
2020年1月14日
Tkinter
Tkinter Scale

スケールは、ユーザーがスケールに沿ってスライダーノブを動かすことにより、値の範囲から数値を選択できるウィジェットです。
最小値と最大値、およびスケールの解像度を指定できます。スケールは、エントリウィジェットと比較して制限された数値を提供します。
Tkinter スケールの例
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 スケールの方向と解像度
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()
scaleExample = tk.Scale(app,
orient='horizontal',
resolution=0.1,
from_=0,
to=10)
orient='horizontal'
Tkinter スケールのデフォルトの向きは、最初の例に示すように垂直です。水平 Tkinter スケールを取得するには、scale
の orient
属性を horizontal
に指定する必要があります。
resolution=0.1
スケールの解像度は、デフォルト値が 1
の解像度
オプションで変更できます。
Author: Jinku Hu
Founder of DelftStack.com. Jinku has worked in the robotics and automotive industries for over 8 years. He sharpened his coding skills when he needed to do the automatic testing, data collection from remote servers and report creation from the endurance test. He is from an electrical/electronics engineering background but has expanded his interest to embedded electronics, embedded programming and front-/back-end programming.
LinkedIn