在第五章中的seekbar.py中有如下两个方法
def on_seekbar_clicked(self, event=None):
if event.x > 0 and event.x < self.width:
self.slide_to_position(event.x)
self.coords(self.red_rectangle, 0, 0, new_position, new_position)
self.coords(self.seekbar_knob, new_position, 0)
self.event_generate("<<SeekbarPositionChanged>>", x=new_position)
self.event_generate("<<SeekbarPositionChanged>>", x=new_position)这句代码的位置错了,应该改成:
def on_seekbar_clicked(self, event=None):
if event.x > 0 and event.x < self.width:
self.slide_to_position(event.x)
self.event_generate("<<SeekbarPositionChanged>>", x=event.x)
def slide_to_position(self, new_position):
self.coords(self.red_rectangle, 0, 0, new_position, new_position)
self.coords(self.seekbar_knob, new_position, 0)
是应该当seekbar被点击后才用自定义事件传递点击位置,从而调整播放时间。
bug在于不是不能实现上述功能,而是会产生一个新的播放器去播放调整后的时间。