def mousewheel_scroll(self, axis, event): bbox = self.root_canvas.bbox(tk.ALL) dims = (self.root_canvas.winfo_width(), self.root_canvas.winfo_height()) if not bbox or (dims[axis] >= (bbox[2 + axis] - bbox[axis])): return self._pending_scroll_counts[axis] += 1 if self._scrolling: return self._scrolling = True try: axis_char = "xy"[axis] scroll_func = getattr(self.root_canvas, axis_char + "view_scroll") scroll_inc = ( getattr(self.app_root, "scroll_increment_" + axis_char, 20) * self._pending_scroll_counts[axis] * get_mouse_delta(event)) self._pending_scroll_counts[axis] = 0 scroll_func(int(scroll_inc), "units") self.root_canvas.update() self._scrolling = False except Exception: self._scrolling = False raise
def mousewheel_scroll_x(self, e): # prevent scrolling if the root_canvas.bbox width >= canvas width bbox = self.root_canvas.bbox(tk.ALL) if not bbox or (self.root_canvas.winfo_width() >= bbox[2] - bbox[0]): return delta = getattr(self.app_root, "scroll_increment_x", 20) self.root_canvas.xview_scroll(int(get_mouse_delta(e) * delta), "units")
def mousewheel_scroll_y(self, e): # prevent scrolling if the root_canvas.bbox height >= canvas height bbox = self.root_canvas.bbox(tk.ALL) if not bbox or (self.root_canvas.winfo_height() >= bbox[3] - bbox[1]): return delta = getattr(self.app_root, "scroll_increment_y", 20) self.root_canvas.yview_scroll(int(get_mouse_delta(e) * delta), "units")
def _mousewheel_scroll(self, e): if not self.should_scroll(e) or (self.option_box_visible or self.disabled): return delta = get_mouse_delta(e) if delta < 0: self.decrement_sel() elif delta > 0: self.increment_sel()
def mousewheel_scroll_y(self, e): if self.should_scroll(e): delta = ( getattr(self.tag_window.app_root, "scroll_increment_x", 20) * int(widgets.get_mouse_delta(e))) self.check_canvas.yview_scroll(delta, "units")