# Path: pyDEA/core/gui_modules/scrollable_frame_gui.py
# class MouseWheel(object):
#     ''' This class bind scrolling events to a scroll object.
#     '''
#     def __init__(self, root, factor=1):
#         global os
#         self.activeArea = None
#         if type(factor) == int:
#             self.factor = factor
#         else:
#             raise Exception("Factor must be an integer.")
# 
#         if os == "Linux":
#             root.bind_all('<4>', self.onMouseWheel,  add='+')
#             root.bind_all('<5>', self.onMouseWheel,  add='+')
#         else:
#             # Windows and MacOS
#             root.bind_all("<MouseWheel>", self.onMouseWheel,  add='+')
# 
#         self.root = root
# 
#     def onMouseWheel(self, event):
#         if self.activeArea:
#             self.activeArea.onMouseWheel(event)
# 
#     def mouseWheel_bind(self, widget):
#         self.activeArea = widget
# 
#     def mouseWheel_unbind(self):
#         self.activeArea = None
# 
#     @staticmethod
#     def build_function_onMouseWheel(widget, orient, scrollbar, factor=1):
#         view_command = getattr(widget, orient+'view')
#         if os == 'Linux':
#             def onMouseWheel(event):
#                 # 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))
# 
#         if xscrollbar and not hasattr(xscrollbar, 'onMouseWheel'):
#                 setattr(xscrollbar, 'onMouseWheel',
#                         self.build_function_onMouseWheel(scrollingArea, 'x',
#                         xscrollbar, self.factor))
# 
#         if yscrollbar and not hasattr(yscrollbar, 'onMouseWheel'):
#                 setattr(yscrollbar, 'onMouseWheel',
#                         self.build_function_onMouseWheel(scrollingArea, 'y',
#                         yscrollbar, self.factor))
# 
#         active_scrollbar_on_mouse_wheel = yscrollbar or xscrollbar
#         if active_scrollbar_on_mouse_wheel:
#             setattr(scrollingArea, 'onMouseWheel',
#                     active_scrollbar_on_mouse_wheel.onMouseWheel)
# 
#         for scrollbar in (xscrollbar, yscrollbar):
#             if scrollbar:
#                 scrollbar.bind(
#                     '<Enter>', lambda event,
#                     scrollbar=scrollbar: self.mouseWheel_bind(scrollbar))
#                 scrollbar.bind('<Leave>',
#                                lambda event: self.mouseWheel_unbind())
# 
# 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)


from tkinter import W, E, S, N, LEFT, VERTICAL
from tkinter import IntVar, ALL
from tkinter.ttk import Frame, Label, Scrollbar
from tkinter.ttk import Separator, LabelFrame, Checkbutton
from pyDEA.core.gui_modules.scrollable_frame_gui import MouseWheel
from pyDEA.core.gui_modules.custom_canvas_gui import StyledCanvas
        '''
        yScrollbar = Scrollbar(self, orient=VERTICAL)
        yScrollbar.grid(row=2, column=3, sticky=N+S)

        canvas = StyledCanvas(self, height=HEIGHT_WITHOUT_CHECKBOXES,
                              yscrollcommand=yScrollbar.set)
        self.canvas = canvas
        canvas.grid(row=2, column=0, columnspan=3, sticky=N+E+W)

        self._config_columns(self)
        canvas.columnconfigure(0, weight=1)

        if self.add_headers:
            non_discr_lbl = Label(self, text='Non-\ndiscretionary')
            non_discr_lbl.grid(row=0, column=1, padx=3, pady=1)
            weakly_disp_lbl = Label(self, text='Weakly\ndisposable')
            weakly_disp_lbl.grid(row=0, column=2, padx=3, pady=1)
            sep = Separator(self)
            sep.grid(row=1, column=0, columnspan=3, sticky=E+W, pady=10, padx=3)

        self.frame_with_boxes = Frame(canvas)
        self._config_columns(self.frame_with_boxes)
        self.frame_with_boxes.grid(sticky=N+S+W+E, pady=15, padx=3)

        canvas.create_window(0, 0, window=self.frame_with_boxes, anchor=N+W)
        canvas.update_idletasks()

        canvas['scrollregion'] = (0, 0, 0, HEIGHT_WITHOUT_CHECKBOXES)
        yScrollbar['command'] = canvas.yview


# Path: pyDEA/core/gui_modules/scrollable_frame_gui.py
# class MouseWheel(object):
#     ''' This class bind scrolling events to a scroll object.
#     '''
#     def __init__(self, root, factor=1):
#         global os
#         self.activeArea = None
#         if type(factor) == int:
#             self.factor = factor
#         else:
#             raise Exception("Factor must be an integer.")
# 
#         if os == "Linux":
#             root.bind_all('<4>', self.onMouseWheel,  add='+')
#             root.bind_all('<5>', self.onMouseWheel,  add='+')
#         else:
#             # Windows and MacOS
#             root.bind_all("<MouseWheel>", self.onMouseWheel,  add='+')
# 
#         self.root = root
# 
#     def onMouseWheel(self, event):
#         if self.activeArea:
#             self.activeArea.onMouseWheel(event)
# 
#     def mouseWheel_bind(self, widget):
#         self.activeArea = widget
# 
#     def mouseWheel_unbind(self):
#         self.activeArea = None
# 
#     @staticmethod
#     def build_function_onMouseWheel(widget, orient, scrollbar, factor=1):
#         view_command = getattr(widget, orient+'view')
#         if os == 'Linux':
#             def onMouseWheel(event):
#                 # 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))
# 
#         if xscrollbar and not hasattr(xscrollbar, 'onMouseWheel'):
#                 setattr(xscrollbar, 'onMouseWheel',
#                         self.build_function_onMouseWheel(scrollingArea, 'x',
#                         xscrollbar, self.factor))
# 
#         if yscrollbar and not hasattr(yscrollbar, 'onMouseWheel'):
#                 setattr(yscrollbar, 'onMouseWheel',
#                         self.build_function_onMouseWheel(scrollingArea, 'y',
#                         yscrollbar, self.factor))
# 
#         active_scrollbar_on_mouse_wheel = yscrollbar or xscrollbar
#         if active_scrollbar_on_mouse_wheel:
#             setattr(scrollingArea, 'onMouseWheel',
#                     active_scrollbar_on_mouse_wheel.onMouseWheel)
# 
#         for scrollbar in (xscrollbar, yscrollbar):
#             if scrollbar:
#                 scrollbar.bind(
#                     '<Enter>', lambda event,
#                     scrollbar=scrollbar: self.mouseWheel_bind(scrollbar))
#                 scrollbar.bind('<Leave>',
#                                lambda event: self.mouseWheel_unbind())
# 
# 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/gui_modules/categories_checkbox_gui.py
from tkinter import W, E, S, N, LEFT, VERTICAL
from tkinter import IntVar, ALL
from tkinter.ttk import Frame, Label, Scrollbar
from tkinter.ttk import Separator, LabelFrame, Checkbutton
from pyDEA.core.gui_modules.scrollable_frame_gui import MouseWheel
from pyDEA.core.gui_modules.custom_canvas_gui import StyledCanvas

        '''
        yScrollbar = Scrollbar(self, orient=VERTICAL)
        yScrollbar.grid(row=2, column=3, sticky=N+S)

        canvas = StyledCanvas(self, height=HEIGHT_WITHOUT_CHECKBOXES,
                              yscrollcommand=yScrollbar.set)
        self.canvas = canvas
        canvas.grid(row=2, column=0, columnspan=3, sticky=N+E+W)

        self._config_columns(self)
        canvas.columnconfigure(0, weight=1)

        if self.add_headers:
            non_discr_lbl = Label(self, text='Non-\ndiscretionary')
            non_discr_lbl.grid(row=0, column=1, padx=3, pady=1)
            weakly_disp_lbl = Label(self, text='Weakly\ndisposable')
            weakly_disp_lbl.grid(row=0, column=2, padx=3, pady=1)
            sep = Separator(self)
            sep.grid(row=1, column=0, columnspan=3, sticky=E+W, pady=10, padx=3)

        self.frame_with_boxes = Frame(canvas)
        self._config_columns(self.frame_with_boxes)
        self.frame_with_boxes.grid(sticky=N+S+W+E, pady=15, padx=3)

        canvas.create_window(0, 0, window=self.frame_with_boxes, anchor=N+W)
        canvas.update_idletasks()

        canvas['scrollregion'] = (0, 0, 0, HEIGHT_WITHOUT_CHECKBOXES)
        yScrollbar['command'] = canvas.yview


        MouseWheel(self).add_scrolling(canvas, yscrollbar=yScrollbar)