tkinter 滑块粘在一起

tkinter sliders are stuck together

我在分离这 2 个滑块时遇到问题。他们似乎一起跟踪,但变量似乎不是唯一的,我不明白为什么。有人可以帮忙吗?

import tkinter as tk

sBoard = tk.Tk()
sBoard.geometry("800x400")

ch1_Frame = tk.LabelFrame(sBoard, text = "CH 1", bd = 5)

ch1_val = 0
ch1 = tk.Scale(ch1_Frame, variable = ch1_val, from_ =100, to = 0, showvalue = 0, width = 25, length = 200)
ch1.pack()

button1 = tk.Button(ch1_Frame, text = "Power")
button1.pack()

ch1_Frame.place(x=25, y=50)

ch2_Frame = tk.LabelFrame(sBoard, text = "CH 2", bd = 5)

ch2_val = 0
ch2 = tk.Scale(ch2_Frame, variable = ch2_val, from_ =100, to = 0, showvalue = 0, width = 25, length = 200)
ch2.pack()

button2 = tk.Button(ch2_Frame, text = "Power")
button2.pack()

ch2_Frame.place(x=150, y=50)

sBoard.mainloop()

变量必须是tkinter变量类型之一,例如IntVar:

ch1_val = tk.IntVar()
ch1 = tk.Scale(ch1_Frame, variable = ch1_val, from_ =100, to = 0, showvalue = 0, width = 25, length = 200)
ch1.pack()