commit 32
This commit is contained in:
Binary file not shown.
@@ -484,12 +484,20 @@ class CustomFileDialog(tk.Toplevel):
|
|||||||
scrollregion=canvas.bbox("all")))
|
scrollregion=canvas.bbox("all")))
|
||||||
|
|
||||||
def _on_mouse_wheel(event):
|
def _on_mouse_wheel(event):
|
||||||
delta = -1 if event.num == 4 else 1
|
# Determine the scroll direction and magnitude
|
||||||
|
if event.num == 4: # Scroll up on Linux
|
||||||
|
delta = -1
|
||||||
|
elif event.num == 5: # Scroll down on Linux
|
||||||
|
delta = 1
|
||||||
|
else: # MouseWheel event for Windows/macOS
|
||||||
|
delta = -1 * int(event.delta / 120)
|
||||||
canvas.yview_scroll(delta, "units")
|
canvas.yview_scroll(delta, "units")
|
||||||
|
|
||||||
canvas.bind_all("<MouseWheel>", _on_mouse_wheel)
|
# Bind mouse wheel events to the canvas and the container frame
|
||||||
canvas.bind_all("<Button-4>", _on_mouse_wheel)
|
for widget in [canvas, container_frame]:
|
||||||
canvas.bind_all("<Button-5>", _on_mouse_wheel)
|
widget.bind("<MouseWheel>", _on_mouse_wheel)
|
||||||
|
widget.bind("<Button-4>", _on_mouse_wheel)
|
||||||
|
widget.bind("<Button-5>", _on_mouse_wheel)
|
||||||
|
|
||||||
items, error, warning = self._get_sorted_items()
|
items, error, warning = self._get_sorted_items()
|
||||||
if warning:
|
if warning:
|
||||||
@@ -522,11 +530,16 @@ class CustomFileDialog(tk.Toplevel):
|
|||||||
name, 14), anchor="center", style="Item.TLabel")
|
name, 14), anchor="center", style="Item.TLabel")
|
||||||
name_label.pack(fill="x", expand=True)
|
name_label.pack(fill="x", expand=True)
|
||||||
Tooltip(item_frame, name)
|
Tooltip(item_frame, name)
|
||||||
|
# Bind events to all individual widgets so scrolling works everywhere
|
||||||
for widget in [item_frame, icon_label, name_label]:
|
for widget in [item_frame, icon_label, name_label]:
|
||||||
widget.bind("<Double-Button-1>", lambda e,
|
widget.bind("<Double-Button-1>", lambda e,
|
||||||
p=path: self.on_item_double_click(p))
|
p=path: self.on_item_double_click(p))
|
||||||
widget.bind("<Button-1>", lambda e, p=path,
|
widget.bind("<Button-1>", lambda e, p=path,
|
||||||
f=item_frame: self.on_item_select(p, f))
|
f=item_frame: self.on_item_select(p, f))
|
||||||
|
widget.bind("<MouseWheel>", _on_mouse_wheel)
|
||||||
|
widget.bind("<Button-4>", _on_mouse_wheel)
|
||||||
|
widget.bind("<Button-5>", _on_mouse_wheel)
|
||||||
|
|
||||||
col = (col + 1) % col_count
|
col = (col + 1) % col_count
|
||||||
if col == 0:
|
if col == 0:
|
||||||
row += 1
|
row += 1
|
||||||
|
Reference in New Issue
Block a user