CustomTkinter
CustomTkinter copied to clipboard
Mouse wheel doesn't work on ScrollableFrame
I tried scrollable_frame_example.py
on linux machine (endeavour os), the mouse wheel doesn't work if i scroll the frame.
But, i tried it on windows machine (windows 10), it works perfectly.
Probably a bug in the mouse-wheel binding of CTkScrollableFrame.
In windows, the mouse-wheel is binded using <MouseWheel>
method, but for linux machine the mouse-wheel binding is <Button-4>
for up scroll and <Button-5>
for down scroll (which is currently not implemented).
For now, you can fix this by adding those bindings in your scroll frame:
scroll_frame = customtkinter.CTkScrollableFrame(root)
scroll_frame.bind_all("<Button-4>", lambda e: scroll_frame._parent_canvas.yview("scroll", -1, "units"))
scroll_frame.bind_all("<Button-5>", lambda e: scroll_frame._parent_canvas.yview("scroll", 1, "units"))
@TomSchimansky, please add those binding and improve this function inside ctk_scrollable_frame.py.
Just a word of warning. I tested the above solution, and if you have another scrollable widget in the frame, it is susceptible to the scrolling being concurrently activated. When you scroll the 2nd widget (I used CTkTextbox), it also causes scrolling of the CTkScrollableFrame.
This is still an issue for me.
Us moment bro
Just a word of warning. I tested the above solution, and if you have another scrollable widget in the frame, it is susceptible to the scrolling being concurrently activated. When you scroll the 2nd widget (I used CTkTextbox), it also causes scrolling of the CTkScrollableFrame.
bro that code has a bug instead of .bind_all() use .bind()
will the scroll function still work on windows if I make those adjustments for my linux and package it later?
will the scroll function still work on windows if I make those adjustments for my linux and package it later?
If u are asking me then yes it will work on windows as well it wont create any issue. Simulaneously it will also work on linux I have tried on both Os. Just checkout the pr that i have added on top PR #2089
Just a word of warning. I tested the above solution, and if you have another scrollable widget in the frame, it is susceptible to the scrolling being concurrently activated. When you scroll the 2nd widget (I used CTkTextbox), it also causes scrolling of the CTkScrollableFrame.
Yeah, unfortunately bind_all fires off regardless of which frame you scroll in for me. This is the current solution in my TabView:
self.settings_frame = SettingsFrame(self.tab("Settings"))
self.settings_frame.pack(expand=True, fill='both')
self.stats_frame = StatsFrame(self.tab("Stats"))
self.stats_frame.pack(expand=True, fill='both')
self.stats_frame.bind_all("<Button-4>", lambda e: [frame._parent_canvas.yview("scroll", -1, "units") for frame in (self.stats_frame, self.settings_frame)])
self.stats_frame.bind_all("<Button-5>", lambda e: [frame._parent_canvas.yview("scroll", 1, "units") for frame in (self.stats_frame, self.settings_frame)])
will the scroll function still work on windows if I make those adjustments for my linux and package it later?
If u are asking me then yes it will work on windows as well it wont create any issue. Simulaneously it will also work on linux I have tried on both Os. Just checkout the pr that i have added on top PR #2089
Hi @Gabbar-v7. I haven't been able to create a PR, since Github mandated 2FA. Any tips on how I go about this?