# Path: pyDEA/core/gui_modules/custom_canvas_gui.py
# class StyledCanvas(Canvas):
#     ''' Implements Canvas object with a custom background colour.
# 
#         Args:
#             parent (Tk object): parent of this widget.
#     '''
#     def __init__(self, parent, *args, **kw):
#         super().__init__(parent, *args, **kw)
#         self.configure(background=bg_color)
# 
# Path: pyDEA/core/utils/dea_utils.py
# def on_canvas_resize(canvas):
#     ''' This function updates scroll region of the canvas.
#         It should be called on canvas resize.
# 
#         Args:
#             canvas (Canvas): canvas
#     '''
#     canvas.update_idletasks()
#     yscroll = 0
#     xscroll = 0
#     if canvas.bbox(ALL)[2] > canvas.winfo_width():
#         yscroll = canvas.bbox(ALL)[2]
#     if canvas.bbox(ALL)[3] > canvas.winfo_height():
#         xscroll = canvas.bbox(ALL)[3]
#     canvas['scrollregion'] = (0, 0, yscroll, xscroll)


from tkinter import VERTICAL, Y, RIGHT, LEFT, BOTH, N, W
from tkinter.ttk import Frame, Scrollbar
from pyDEA.core.gui_modules.custom_canvas_gui import StyledCanvas
from pyDEA.core.utils.dea_utils import on_canvas_resize
import platform
                # scroll moves only when it is not disables

                if (len(scrollbar.state()) == 0 or
                        scrollbar.state()[0] != 'disabled'):
                    if event.num == 4:
                        view_command("scroll", (-1)*factor, "units")
                    elif event.num == 5:
                        view_command("scroll", factor, "units")

        elif os == 'Windows':
            def onMouseWheel(event):
                if (len(scrollbar.state()) == 0 or
                        scrollbar.state()[0] != 'disabled'):
                    view_command("scroll", (-1)*int((event.delta/120)*factor),
                                 "units")

        elif os == 'Darwin':
            def onMouseWheel(event):
                if (len(scrollbar.state()) == 0 or
                        scrollbar.state()[0] != 'disabled'):
                    view_command("scroll", event.delta, "units")

        return onMouseWheel

    def add_scrolling(self, scrollingArea, xscrollbar=None, yscrollbar=None):
        scrollingArea.bind('<Enter>',
                           lambda event: self.mouseWheel_bind(scrollingArea))
        scrollingArea.bind('<Leave>',
                           lambda event: self.mouseWheel_unbind())
        scrollingArea.bind('<Configure>',

# Path: pyDEA/core/gui_modules/custom_canvas_gui.py
# class StyledCanvas(Canvas):
#     ''' Implements Canvas object with a custom background colour.
# 
#         Args:
#             parent (Tk object): parent of this widget.
#     '''
#     def __init__(self, parent, *args, **kw):
#         super().__init__(parent, *args, **kw)
#         self.configure(background=bg_color)
# 
# Path: pyDEA/core/utils/dea_utils.py
# def on_canvas_resize(canvas):
#     ''' This function updates scroll region of the canvas.
#         It should be called on canvas resize.
# 
#         Args:
#             canvas (Canvas): canvas
#     '''
#     canvas.update_idletasks()
#     yscroll = 0
#     xscroll = 0
#     if canvas.bbox(ALL)[2] > canvas.winfo_width():
#         yscroll = canvas.bbox(ALL)[2]
#     if canvas.bbox(ALL)[3] > canvas.winfo_height():
#         xscroll = canvas.bbox(ALL)[3]
#     canvas['scrollregion'] = (0, 0, yscroll, xscroll)


# Path: pyDEA/core/gui_modules/scrollable_frame_gui.py
from tkinter import VERTICAL, Y, RIGHT, LEFT, BOTH, N, W
from tkinter.ttk import Frame, Scrollbar
from pyDEA.core.gui_modules.custom_canvas_gui import StyledCanvas
from pyDEA.core.utils.dea_utils import on_canvas_resize
import platform

                # scroll moves only when it is not disables

                if (len(scrollbar.state()) == 0 or
                        scrollbar.state()[0] != 'disabled'):
                    if event.num == 4:
                        view_command("scroll", (-1)*factor, "units")
                    elif event.num == 5:
                        view_command("scroll", factor, "units")

        elif os == 'Windows':
            def onMouseWheel(event):
                if (len(scrollbar.state()) == 0 or
                        scrollbar.state()[0] != 'disabled'):
                    view_command("scroll", (-1)*int((event.delta/120)*factor),
                                 "units")

        elif os == 'Darwin':
            def onMouseWheel(event):
                if (len(scrollbar.state()) == 0 or
                        scrollbar.state()[0] != 'disabled'):
                    view_command("scroll", event.delta, "units")

        return onMouseWheel

    def add_scrolling(self, scrollingArea, xscrollbar=None, yscrollbar=None):
        scrollingArea.bind('<Enter>',
                           lambda event: self.mouseWheel_bind(scrollingArea))
        scrollingArea.bind('<Leave>',
                           lambda event: self.mouseWheel_unbind())
        scrollingArea.bind('<Configure>',

                           lambda event: on_canvas_resize(scrollingArea))