# Buggy code
def __init__(self, parent, config, imtypes):
    # Settting the GUI size and panels design
    displays = (
        wx.Display(i) for i in range(wx.Display.GetCount())
    )  # Gets the number of displays
    screenSizes = [
        display.GetGeometry().GetSize() for display in displays
    ]  # Gets the size of each display
    index = 0  # For display 1.
    screenWidth = screenSizes[index][0]
    screenHeight = screenSizes[index][1]
    self.gui_size = (screenWidth * 0.7, screenHeight * 0.85)
    self.imtypes = imtypes  # imagetypes to look for in folder e.g. *.png

    wx.Frame.__init__(
        self,
        parent,
        id=wx.ID_ANY,
        title="DeepLabCut2.0 - Labeling ToolBox",
        size=wx.Size(self.gui_size),
        pos=wx.DefaultPosition,
        style=wx.RESIZE_BORDER | wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL,
    )
    self.statusbar = self.CreateStatusBar()
    self.statusbar.SetStatusText(
        "Looking for a folder to start labeling. Click 'Load frames' to begin."
    )
    self.Bind(wx.EVT_CHAR_HOOK, self.OnKeyPressed)

    self.SetSizeHints(
        wx.Size(self.gui_size)
    )  #  This sets the minimum size of the GUI. It can scale now!
    ###################################################################################################################################################

    # Spliting the frame into top and bottom panels. Bottom panels contains the widgets. The top panel is for showing images and plotting!

    topSplitter = wx.SplitterWindow(self)
    vSplitter = wx.SplitterWindow(topSplitter)

    self.image_panel = ImagePanel(vSplitter, config, self.gui_size)
    self.choice_panel = ScrollPanel(vSplitter)
    vSplitter.SplitVertically(
        self.image_panel, self.choice_panel, sashPosition=self.gui_size[0] * 0.8
    )
    vSplitter.SetSashGravity(1)
    self.widget_panel = WidgetPanel(topSplitter)
    topSplitter.SplitHorizontally(
        vSplitter, self.widget_panel, sashPosition=self.gui_size[1] * 0.83
    )  # 0.9
    topSplitter.SetSashGravity(1)
    sizer = wx.BoxSizer(wx.VERTICAL)
    sizer.Add(topSplitter, 1, wx.EXPAND)
    self.SetSizer(sizer)

    ###################################################################################################################################################
    # Add Buttons to the WidgetPanel and bind them to their respective functions.

    widgetsizer = wx.WrapSizer(orient=wx.HORIZONTAL)
    self.load = wx.Button(self.widget_panel, id=wx.ID_ANY, label="Load frames")
    widgetsizer.Add(self.load, 1, wx.ALL, 15)
    self.load.Bind(wx.EVT_BUTTON, self.browseDir)

    self.prev = wx.Button(self.widget_panel, id=wx.ID_ANY, label="<<Previous")
    widgetsizer.Add(self.prev, 1, wx.ALL, 15)
    self.prev.Bind(wx.EVT_BUTTON, self.prevImage)
    self.prev.Enable(False)

    self.next = wx.Button(self.widget_panel, id=wx.ID_ANY, label="Next>>")
    widgetsizer.Add(self.next, 1, wx.ALL, 15)
    self.next.Bind(wx.EVT_BUTTON, self.nextImage)
    self.next.Enable(False)

    self.help = wx.Button(self.widget_panel, id=wx.ID_ANY, label="Help")
    widgetsizer.Add(self.help, 1, wx.ALL, 15)
    self.help.Bind(wx.EVT_BUTTON, self.helpButton)
    self.help.Enable(True)
    #
    self.zoom = wx.ToggleButton(self.widget_panel, label="Zoom")
    widgetsizer.Add(self.zoom, 1, wx.ALL, 15)
    self.zoom.Bind(wx.EVT_TOGGLEBUTTON, self.zoomButton)
    self.widget_panel.SetSizer(widgetsizer)
    self.zoom.Enable(False)

    self.home = wx.Button(self.widget_panel, id=wx.ID_ANY, label="Home")
    widgetsizer.Add(self.home, 1, wx.ALL, 15)
    self.home.Bind(wx.EVT_BUTTON, self.homeButton)
    self.widget_panel.SetSizer(widgetsizer)
    self.home.Enable(False)

    self.pan = wx.ToggleButton(self.widget_panel, id=wx.ID_ANY, label="Pan")
    widgetsizer.Add(self.pan, 1, wx.ALL, 15)
    self.pan.Bind(wx.EVT_TOGGLEBUTTON, self.panButton)
    self.widget_panel.SetSizer(widgetsizer)
    self.pan.Enable(False)

    self.lock = wx.CheckBox(self.widget_panel, id=wx.ID_ANY, label="Lock View")
    widgetsizer.Add(self.lock, 1, wx.ALL, 15)
    self.lock.Bind(wx.EVT_CHECKBOX, self.lockChecked)
    self.widget_panel.SetSizer(widgetsizer)
    self.lock.Enable(False)

    self.save = wx.Button(self.widget_panel, id=wx.ID_ANY, label="Save")
    widgetsizer.Add(self.save, 1, wx.ALL, 15)
    self.save.Bind(wx.EVT_BUTTON, self.saveDataSet)
    self.save.Enable(False)

    self.delete = wx.Button(self.widget_panel, id=wx.ID_ANY, label="Delete Frame")
    widgetsizer.Add(self.delete, 1, wx.ALL, 15)
    self.delete.Bind(wx.EVT_BUTTON, self.deleteImage)
    self.delete.Enable(False)

    widgetsizer.AddStretchSpacer(15)
    self.quit = wx.Button(self.widget_panel, id=wx.ID_ANY, label="Quit")
    widgetsizer.Add(self.quit, 1, wx.ALL | wx.ALIGN_RIGHT, 15)
    self.quit.Bind(wx.EVT_BUTTON, self.quitButton)

    self.widget_panel.SetSizer(widgetsizer)
    self.widget_panel.SetSizerAndFit(widgetsizer)
    self.widget_panel.Layout()

    ###############################################################################################################################
    # Variables initialization

    self.currentDirectory = os.getcwd()
    self.index = []
    self.iter = []
    self.file = 0
    self.updatedCoords = []
    self.dataFrame = None
    self.config_file = config
    self.new_labels = False
    self.buttonCounter = []
    self.bodyparts2plot = []
    self.drs = []
    self.num = []
    self.view_locked = False
    # Workaround for MAC - xlim and ylim changed events seem to be triggered too often so need to make sure that the
    # xlim and ylim have actually changed before turning zoom off
    self.prezoom_xlim = []
    self.prezoom_ylim = []


# Traceback (IndexError)
pythonw -m deeplabcut
Starting GUI...
Found new frames..
Traceback (most recent call last):
File "/Users/brandonjackson/opt/miniconda3/envs/dlc/lib/python3.7/site-packages/deeplabcut/generate_training_dataset/labeling_toolbox.py", line 767, in nextImage
self.updatedCoords = MainFrame.getLabels(self, self.iter)
File "/Users/brandonjackson/opt/miniconda3/envs/dlc/lib/python3.7/site-packages/deeplabcut/generate_training_dataset/labeling_toolbox.py", line 845, in getLabels
self.dataFrame[self.scorer][bp]["x"].values[self.iter],
IndexError: index 1 is out of bounds for axis 0 with size 1

# Fixed code
def __init__(self, parent, config, imtypes):
    # Settting the GUI size and panels design
    displays = (
        wx.Display(i) for i in range(wx.Display.GetCount())
    )  # Gets the number of displays
    screenSizes = [
        display.GetGeometry().GetSize() for display in displays
    ]  # Gets the size of each display
    index = 0  # For display 1.
    screenWidth = screenSizes[index][0]
    screenHeight = screenSizes[index][1]
    self.gui_size = (screenWidth * 0.7, screenHeight * 0.85)
    self.imtypes = imtypes  # imagetypes to look for in folder e.g. *.png

    wx.Frame.__init__(
        self,
        parent,
        id=wx.ID_ANY,
        title="DeepLabCut2.0 - Labeling ToolBox",
        size=wx.Size(self.gui_size),
        pos=wx.DefaultPosition,
        style=wx.RESIZE_BORDER | wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL,
    )
    self.statusbar = self.CreateStatusBar()
    self.statusbar.SetStatusText(
        "Looking for a folder to start labeling. Click 'Load frames' to begin."
    )
    self.Bind(wx.EVT_CHAR_HOOK, self.OnKeyPressed)

    self.SetSizeHints(
        wx.Size(self.gui_size)
    )  #  This sets the minimum size of the GUI. It can scale now!
    ###################################################################################################################################################

    # Spliting the frame into top and bottom panels. Bottom panels contains the widgets. The top panel is for showing images and plotting!

    topSplitter = wx.SplitterWindow(self)
    vSplitter = wx.SplitterWindow(topSplitter)

    self.image_panel = ImagePanel(vSplitter, config, self.gui_size)
    self.choice_panel = ScrollPanel(vSplitter)
    vSplitter.SplitVertically(
        self.image_panel, self.choice_panel, sashPosition=self.gui_size[0] * 0.8
    )
    vSplitter.SetSashGravity(1)
    self.widget_panel = WidgetPanel(topSplitter)
    topSplitter.SplitHorizontally(
        vSplitter, self.widget_panel, sashPosition=self.gui_size[1] * 0.83
    )  # 0.9
    topSplitter.SetSashGravity(1)
    sizer = wx.BoxSizer(wx.VERTICAL)
    sizer.Add(topSplitter, 1, wx.EXPAND)
    self.SetSizer(sizer)

    ###################################################################################################################################################
    # Add Buttons to the WidgetPanel and bind them to their respective functions.

    widgetsizer = wx.WrapSizer(orient=wx.HORIZONTAL)
    self.load = wx.Button(self.widget_panel, id=wx.ID_ANY, label="Load frames")
    widgetsizer.Add(self.load, 1, wx.ALL, 15)
    self.load.Bind(wx.EVT_BUTTON, self.browseDir)

    self.prev = wx.Button(self.widget_panel, id=wx.ID_ANY, label="<<Previous")
    widgetsizer.Add(self.prev, 1, wx.ALL, 15)
    self.prev.Bind(wx.EVT_BUTTON, self.prevImage)
    self.prev.Enable(False)

    self.next = wx.Button(self.widget_panel, id=wx.ID_ANY, label="Next>>")
    widgetsizer.Add(self.next, 1, wx.ALL, 15)
    self.next.Bind(wx.EVT_BUTTON, self.nextImage)
    self.next.Enable(False)

    self.help = wx.Button(self.widget_panel, id=wx.ID_ANY, label="Help")
    widgetsizer.Add(self.help, 1, wx.ALL, 15)
    self.help.Bind(wx.EVT_BUTTON, self.helpButton)
    self.help.Enable(True)
    #
    self.zoom = wx.ToggleButton(self.widget_panel, label="Zoom")
    widgetsizer.Add(self.zoom, 1, wx.ALL, 15)
    self.zoom.Bind(wx.EVT_TOGGLEBUTTON, self.zoomButton)
    self.widget_panel.SetSizer(widgetsizer)
    self.zoom.Enable(False)

    self.home = wx.Button(self.widget_panel, id=wx.ID_ANY, label="Home")
    widgetsizer.Add(self.home, 1, wx.ALL, 15)
    self.home.Bind(wx.EVT_BUTTON, self.homeButton)
    self.widget_panel.SetSizer(widgetsizer)
    self.home.Enable(False)

    self.pan = wx.ToggleButton(self.widget_panel, id=wx.ID_ANY, label="Pan")
    widgetsizer.Add(self.pan, 1, wx.ALL, 15)
    self.pan.Bind(wx.EVT_TOGGLEBUTTON, self.panButton)
    self.widget_panel.SetSizer(widgetsizer)
    self.pan.Enable(False)

    self.lock = wx.CheckBox(self.widget_panel, id=wx.ID_ANY, label="Lock View")
    widgetsizer.Add(self.lock, 1, wx.ALL, 15)
    self.lock.Bind(wx.EVT_CHECKBOX, self.lockChecked)
    self.widget_panel.SetSizer(widgetsizer)
    self.lock.Enable(False)

    self.save = wx.Button(self.widget_panel, id=wx.ID_ANY, label="Save")
    widgetsizer.Add(self.save, 1, wx.ALL, 15)
    self.save.Bind(wx.EVT_BUTTON, self.saveDataSet)
    self.save.Enable(False)

    widgetsizer.AddStretchSpacer(15)
    self.quit = wx.Button(self.widget_panel, id=wx.ID_ANY, label="Quit")
    widgetsizer.Add(self.quit, 1, wx.ALL | wx.ALIGN_RIGHT, 15)
    self.quit.Bind(wx.EVT_BUTTON, self.quitButton)

    self.widget_panel.SetSizer(widgetsizer)
    self.widget_panel.SetSizerAndFit(widgetsizer)
    self.widget_panel.Layout()

    ###############################################################################################################################
    # Variables initialization

    self.currentDirectory = os.getcwd()
    self.index = []
    self.iter = []
    self.file = 0
    self.updatedCoords = []
    self.dataFrame = None
    self.config_file = config
    self.new_labels = False
    self.buttonCounter = []
    self.bodyparts2plot = []
    self.drs = []
    self.num = []
    self.view_locked = False
    # Workaround for MAC - xlim and ylim changed events seem to be triggered too often so need to make sure that the
    # xlim and ylim have actually changed before turning zoom off
    self.prezoom_xlim = []
    self.prezoom_ylim = []