<commit_before>import wx


class LabelViewerPanel(wx.Panel):
    """
    Parent class for other custom panels. Hides the cursor and handles
    keypress events.
    """

    def __init__(self, parent, panel_id, panel_size):
        wx.Panel.__init__(self, parent, id=panel_id, size=panel_size)
        self.frame = parent
        self.panel_id = panel_id
        self.Bind(wx.EVT_CHAR, self.on_keypress)
        self.cursor = wx.StockCursor(wx.CURSOR_BLANK)
        self.BackgroundColour = wx.BLACK
        self.widgets = []

    def set_cursor(self):
        for widget in self.widgets:
            widget.SetCursor(self.cursor)

    def on_keypress(self, event):
        keycode = event.GetKeyCode()
        if keycode == wx.WXK_ESCAPE:
            self.frame.close()


class MainPanel(LabelViewerPanel):
    """
    Main shelf panel. When touched/clicked each object opens a new ObjectPanel.
    """

    def __init__(self, parent, panel_id, panel_size):
        LabelViewerPanel.__init__(self, parent, panel_id, panel_size)

        background_bmp = wx.Bitmap('./images/home.png', wx.BITMAP_TYPE_PNG)
        bg = wx.StaticBitmap(self, id=0, bitmap=background_bmp)

        # Widgets
        img = './images/shelf/duiker_hoof_necklace.png'
        hoof_necklace_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        hoof_necklace = wx.StaticBitmap(bg, id=0, pos=(430, 50),
                                        bitmap=hoof_necklace_bmp)
        self.add_widget(hoof_necklace)

        img = './images/shelf/eggshell_necklace.png'
        eggshell_necklace_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        eggshell_necklace = wx.StaticBitmap(bg, id=0, pos=(936, 50),
                                            bitmap=eggshell_necklace_bmp)
        self.add_widget(eggshell_necklace)

        img = './images/shelf/leather_leggings.png'
        leather_leggings_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        leather_leggings = wx.StaticBitmap(bg, id=0, pos=(690, 300),
                                           bitmap=leather_leggings_bmp)
        self.add_widget(leather_leggings)

        img = './images/shelf/metal_pendant.png'
        metal_pendant_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        metal_pendant = wx.StaticBitmap(bg, id=0, pos=(690, 420),
                                        bitmap=metal_pendant_bmp)
        self.add_widget(metal_pendant)

        img = './images/shelf/ainu_necklaces.png'
        ainu_necklaces_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        ainu_necklaces = wx.StaticBitmap(bg, id=0, pos=(936, 290),
                                         bitmap=ainu_necklaces_bmp)
        self.add_widget(ainu_necklaces)

        img = './images/shelf/jade_necklace.png'
        jade_necklace_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        jade_necklace = wx.StaticBitmap(bg, id=0, pos=(450, 300),
                                        bitmap=jade_necklace_bmp)
        self.add_widget(jade_necklace)

        img = './images/shelf/turquoise_necklace.png'
        turquoise_necklace_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        turquoise_necklace = wx.StaticBitmap(bg, id=0, pos=(530, 300),
                                             bitmap=turquoise_necklace_bmp)
        self.add_widget(turquoise_necklace)

        img = './images/shelf/stone_necklace.png'
        stone_necklace_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        stone_necklace = wx.StaticBitmap(bg, id=0, pos=(430, 430),
                                         bitmap=stone_necklace_bmp)
        self.add_widget(stone_necklace)

        img = './images/shelf/ivory_necklace.png'
        ivory_necklace_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        ivory_necklace = wx.StaticBitmap(bg, id=0, pos=(435, 530),
                                         bitmap=ivory_necklace_bmp)
        self.add_widget(ivory_necklace)

        img = './images/shelf/wood_prayer_beads.png'
        wood_prayer_beads_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        wood_prayer_beads = wx.StaticBitmap(bg, id=0, pos=(670, 530),
                                            bitmap=wood_prayer_beads_bmp)
        self.add_widget(wood_prayer_beads)

        img = './images/shelf/birch_bark_necklace.png'
        birch_bark_necklace_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        birch_bark_necklace = wx.StaticBitmap(bg, id=0, pos=(800, 530),
                                              bitmap=birch_bark_necklace_bmp)
        self.add_widget(birch_bark_necklace)

        img = './images/shelf/ceramic_necklace.png'
        ceramic_necklace_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        ceramic_necklace = wx.StaticBitmap(bg, id=0, pos=(935, 530),
                                           bitmap=ceramic_necklace_bmp)
        self.add_widget(ceramic_necklace)

        img = './images/shelf/paper_necklace.png'
        paper_necklace_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        paper_necklace = wx.StaticBitmap(bg, id=0, pos=(935, 660),
                                         bitmap=paper_necklace_bmp)
        self.add_widget(paper_necklace)

        img = './images/shelf/teeth_glass_necklace.png'
        teeth_glass_necklace_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        teeth_glass_necklace = wx.StaticBitmap(bg, id=0, pos=(435, 766),
                                               bitmap=teeth_glass_necklace_bmp)
        self.add_widget(teeth_glass_necklace)

        img = './images/shelf/seed_shell_necklace.png'
        seed_shell_necklace_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        seed_shell_necklace = wx.StaticBitmap(bg, id=0, pos=(682, 770),
                                              bitmap=seed_shell_necklace_bmp)
        self.add_widget(seed_shell_necklace)

        img = './images/shelf/seed_necklace.png'
        seed_necklace_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        seed_necklace = wx.StaticBitmap(bg, id=0, pos=(690, 890),
                                        bitmap=seed_necklace_bmp)
        self.add_widget(seed_necklace)

        img = './images/shelf/snail_shell_necklace.png'
        snail_shell_necklace_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        snail_shell_necklace = wx.StaticBitmap(self, id=0, pos=(936, 766),
                                               bitmap=snail_shell_necklace_bmp)
        self.add_widget(snail_shell_necklace)

        # Layout
        # main_sizer = wx.BoxSizer(wx.HORIZONTAL)
        # main_sizer.Add(bg, 0, wx.EXPAND)
        # self.SetSizer(main_sizer)

        self.set_cursor()
        self.SetFocus()

    def add_widget(self, widget):
        widget.Bind(wx.EVT_LEFT_DOWN, self.switch_panel)
        self.widgets.append(widget)

    def switch_panel(self, event):
        self.frame.switch_panel(event.GetEventObject().GetId())


class ObjectPanel(LabelViewerPanel):<commit_msg>working background<commit_after>import wx


class LabelViewerPanel(wx.Panel):
    """
    Parent class for other custom panels. Hides the cursor and handles
    keypress events.
    """

    def __init__(self, parent, panel_id, panel_size):
        wx.Panel.__init__(self, parent, id=panel_id, size=panel_size)
        self.frame = parent
        self.panel_id = panel_id
        self.Bind(wx.EVT_CHAR, self.on_keypress)
        self.cursor = wx.StockCursor(wx.CURSOR_BLANK)
        self.BackgroundColour = wx.BLACK
        self.widgets = []

    def set_cursor(self):
        for widget in self.widgets:
            widget.SetCursor(self.cursor)

    def on_keypress(self, event):
        keycode = event.GetKeyCode()
        if keycode == wx.WXK_ESCAPE:
            self.frame.close()


class MainPanel(LabelViewerPanel):
    """
    Main shelf panel. When touched/clicked each object opens a new ObjectPanel.
    """

    def __init__(self, parent, panel_id, panel_size):
        LabelViewerPanel.__init__(self, parent, panel_id, panel_size)
	self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
	self.Bind(wx.EVT_ERASE_BACKGROUND, self.draw_image)

        # background_bmp = wx.Bitmap('./images/home.png', wx.BITMAP_TYPE_PNG)
        # bg = wx.StaticBitmap(self, id=0, bitmap=background_bmp)

        # Widgets
        img = './images/shelf/duiker_hoof_necklace.png'
        hoof_necklace_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        hoof_necklace = wx.StaticBitmap(self, id=0, pos=(430, 50),
                                        bitmap=hoof_necklace_bmp)
        self.add_widget(hoof_necklace)

        img = './images/shelf/eggshell_necklace.png'
        eggshell_necklace_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        eggshell_necklace = wx.StaticBitmap(self, id=0, pos=(936, 50),
                                            bitmap=eggshell_necklace_bmp)
        self.add_widget(eggshell_necklace)

        img = './images/shelf/leather_leggings.png'
        leather_leggings_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        leather_leggings = wx.StaticBitmap(self, id=0, pos=(690, 300),
                                           bitmap=leather_leggings_bmp)
        self.add_widget(leather_leggings)

        img = './images/shelf/metal_pendant.png'
        metal_pendant_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        metal_pendant = wx.StaticBitmap(self, id=0, pos=(690, 420),
                                        bitmap=metal_pendant_bmp)
        self.add_widget(metal_pendant)

        img = './images/shelf/ainu_necklaces.png'
        ainu_necklaces_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        ainu_necklaces = wx.StaticBitmap(self, id=0, pos=(936, 290),
                                         bitmap=ainu_necklaces_bmp)
        self.add_widget(ainu_necklaces)

        img = './images/shelf/jade_necklace.png'
        jade_necklace_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        jade_necklace = wx.StaticBitmap(self, id=0, pos=(450, 300),
                                        bitmap=jade_necklace_bmp)
        self.add_widget(jade_necklace)

        img = './images/shelf/turquoise_necklace.png'
        turquoise_necklace_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        turquoise_necklace = wx.StaticBitmap(self, id=0, pos=(530, 300),
                                             bitmap=turquoise_necklace_bmp)
        self.add_widget(turquoise_necklace)

        img = './images/shelf/stone_necklace.png'
        stone_necklace_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        stone_necklace = wx.StaticBitmap(self, id=0, pos=(430, 430),
                                         bitmap=stone_necklace_bmp)
        self.add_widget(stone_necklace)

        img = './images/shelf/ivory_necklace.png'
        ivory_necklace_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        ivory_necklace = wx.StaticBitmap(self, id=0, pos=(435, 530),
                                         bitmap=ivory_necklace_bmp)
        self.add_widget(ivory_necklace)

        img = './images/shelf/wood_prayer_beads.png'
        wood_prayer_beads_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        wood_prayer_beads = wx.StaticBitmap(self, id=0, pos=(670, 530),
                                            bitmap=wood_prayer_beads_bmp)
        self.add_widget(wood_prayer_beads)

        img = './images/shelf/birch_bark_necklace.png'
        birch_bark_necklace_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        birch_bark_necklace = wx.StaticBitmap(self, id=0, pos=(800, 530),
                                              bitmap=birch_bark_necklace_bmp)
        self.add_widget(birch_bark_necklace)

        img = './images/shelf/ceramic_necklace.png'
        ceramic_necklace_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        ceramic_necklace = wx.StaticBitmap(self, id=0, pos=(935, 530),
                                           bitmap=ceramic_necklace_bmp)
        self.add_widget(ceramic_necklace)

        img = './images/shelf/paper_necklace.png'
        paper_necklace_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        paper_necklace = wx.StaticBitmap(self, id=0, pos=(935, 660),
                                         bitmap=paper_necklace_bmp)
        self.add_widget(paper_necklace)

        img = './images/shelf/teeth_glass_necklace.png'
        teeth_glass_necklace_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        teeth_glass_necklace = wx.StaticBitmap(self, id=0, pos=(435, 766),
                                               bitmap=teeth_glass_necklace_bmp)
        self.add_widget(teeth_glass_necklace)

        img = './images/shelf/seed_shell_necklace.png'
        seed_shell_necklace_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        seed_shell_necklace = wx.StaticBitmap(self, id=0, pos=(682, 770),
                                              bitmap=seed_shell_necklace_bmp)
        self.add_widget(seed_shell_necklace)

        img = './images/shelf/seed_necklace.png'
        seed_necklace_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        seed_necklace = wx.StaticBitmap(self, id=0, pos=(690, 890),
                                        bitmap=seed_necklace_bmp)
        self.add_widget(seed_necklace)

        img = './images/shelf/snail_shell_necklace.png'
        snail_shell_necklace_bmp = wx.Bitmap(img, wx.BITMAP_TYPE_PNG)
        snail_shell_necklace = wx.StaticBitmap(self, id=0, pos=(936, 766),
                                               bitmap=snail_shell_necklace_bmp)
        self.add_widget(snail_shell_necklace)

        # Layout
        # main_sizer = wx.BoxSizer(wx.HORIZONTAL)
        # main_sizer.Add(bg, 0, wx.EXPAND)
        # self.SetSizer(main_sizer)

        self.set_cursor()
        self.SetFocus()

    def draw_image(self, event):
	"""
	Draws the image to the panel's background.
	"""
	dc = event.GetDC()
	if not dc:
	    dc = wx.ClientDC(self)
	    rect = self.GetUpdateRegion().GetBox()
            dc.SetClippingRect(rect)
        dc.Clear()
	image = wx.Bitmap('./images/home.png')
        dc.DrawBitmap(image, 0, 0)
	self.SetFocus()

    def add_widget(self, widget):
        widget.Bind(wx.EVT_LEFT_DOWN, self.switch_panel)
        self.widgets.append(widget)

    def switch_panel(self, event):
        self.frame.switch_panel(event.GetEventObject().GetId())


class ObjectPanel(LabelViewerPanel):
{'fraction_non_alphanumeric': 0.10239635924056034, 'fraction_numerical': 0.01706605987342672, 'mean_word_length': 2.1941857824210764, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 60, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '57991', 'n_tokens_mistral': 5017, 'n_tokens_neox': 4624, 'n_words': 646}