|
1 | 1 | """ |
2 | 2 | Copyright 2018-2019 Juliette Monsel <j_4321 at protonmail dot com> |
3 | 3 | Copyright 2019 Dogeek |
| 4 | +Copyright 2020 RedFantom <redfantom at outlook dot com> |
4 | 5 |
|
5 | 6 | Adapted from PyTkEditor - Python IDE's Notebook widget by |
6 | 7 | Juliette Monsel. Adapted by Dogeek <https://github.com/Dogeek> |
|
9 | 10 |
|
10 | 11 | Notebook with draggable / scrollable tabs |
11 | 12 | """ |
| 13 | +from functools import partial |
12 | 14 | import tkinter as tk |
13 | 15 | from tkinter import ttk |
14 | 16 | from ttkwidgets.utilities import move_widget, parse_geometry, coords_in_box |
@@ -51,11 +53,13 @@ def __init__(self, master=None, tab_nb=0, **kwargs): |
51 | 53 | self.bind("<ButtonRelease-2>", self._b2_press) |
52 | 54 | self.bind("<Enter>", self._on_enter_tab) |
53 | 55 | self.bind("<Leave>", self._on_leave_tab) |
54 | | - self.bind("<MouseWheel>", self._on_mousewheel) |
| 56 | + self.bind("<MouseWheel>", partial(self._on_mousewheel, None)) |
| 57 | + self.bind("<Button-4>", partial(self._on_mousewheel, True)) # Linux mousewheel bind |
| 58 | + self.bind("<Button-5>", partial(self._on_mousewheel, False)) |
55 | 59 |
|
56 | | - def _on_mousewheel(self, event): |
| 60 | + def _on_mousewheel(self, updown, event): |
57 | 61 | if self.hovering_tab: |
58 | | - if event.delta > 0: |
| 62 | + if (updown is None and event.delta > 0) or updown is True: |
59 | 63 | self.master.master.select_prev(True) |
60 | 64 | else: |
61 | 65 | self.master.master.select_next(True) |
@@ -330,7 +334,7 @@ def setup_style(self, bg="#dddddd", activebg="#efefef", pressedbg="#c1c1c1", |
330 | 334 | :param bordercolor: |
331 | 335 | :param focusbordercolor: |
332 | 336 | :param selectbg: |
333 | | - :param selectfb: |
| 337 | + :param selectfg: |
334 | 338 | :param unselectfg: |
335 | 339 | :param disabledfg: |
336 | 340 | :param disabledbg: |
|
0 commit comments