按住按钮时更改 tkinter 旋转框的增量

Change the increment of a tkinter spinbox when the button is held down

正如问题所暗示的,我需要在一段时间后更改旋转框增量。我需要使用旋转框滚动整个 32 位整数(它必须在触摸屏上 运行。任何其他选项也将不胜感激)。然而,用户在滚动时必须保持一定的准确性,但也不应该等到时间结束才从整数的一端到达另一端。如何实现,以便在按住按钮 x 时间后旋转框的增量发生变化?

谢谢!

SpinboxrepeatdelayrepeatInterval 作为参数。如果将它们与计时机制结合起来,就可以达到"quick scroll"的效果,像这样:

import tkinter as tk

class GUI(tk.Tk):
    def __init__(self):
        super().__init__()
        self.s = tk.Spinbox(self)
        self.interval = 0
        self.s["values"] = [i for i in range(32000)]
        self.s.pack()
        self.s.bind('<ButtonPress-1>', self.on_press)
        self.s.bind('<ButtonRelease-1>', self.on_release)

    def on_press(self,event=None):
        self.interval +=1
        if self.interval <=3: #increases speed if button has been hold for 3 seconds
            self.after(1000,self.on_press)
        else:
            self.s.config(repeatdelay=1, repeatinterval=1)

    def on_release(self,event=None):
        self.interval = 0
        self.s.config(repeatdelay=100, repeatinterval=100)

root = GUI()
root.mainloop()