<commit_before>
import wx
import os
from wx import ToolBar as Tbar


from sans.guiframe.gui_style import GUIFRAME_ID
from sans.guiframe.gui_style import GUIFRAME_ICON


def clear_image(image):
    w, h = image.GetSize()
    factor = 155
    compress = lambda x: int(x * factor/255.) + factor
    for y in range(h):
        for x in range(w):
            grey = compress(image.GetGreen(x, y))
            image.SetRGB(x, y, grey, grey, grey)
    if image.HasAlpha():
        image.ConvertAlphaToMask()
    return image

class GUIToolBar(Tbar):
    """
    Implement toolbar for guiframe
    """
    def __init__(self, parent,  *args, **kwds):
        Tbar.__init__(self, parent,  *args, **kwds)
        self.parent = parent
        self.do_layout()
        self.on_bind_button()
       
    def do_layout(self):
        """
        """
        tbar_size = (22, 22)
        button_type =  wx.ITEM_NORMAL
        save_im = GUIFRAME_ICON.SAVE_ICON
        save_im.Rescale(tbar_size[0], tbar_size[1], wx.IMAGE_QUALITY_HIGH)
        save_bmp = save_im.ConvertToBitmap()
        #disable_save_bmp = clear_image(save_im).ConvertToBitmap()
        disable_save_bmp = wx.NullBitmap
        self.AddLabelTool(GUIFRAME_ID.SAVE_ID, 'Save', save_bmp, 
                          disable_save_bmp,button_type, shortHelp='Save')
        self.AddSeparator()
        bookmark_im = GUIFRAME_ICON.BOOKMARK_ICON
        bookmark_im.Rescale(tbar_size[0], tbar_size[1], wx.IMAGE_QUALITY_HIGH)
        bookmark_bmp = bookmark_im.ConvertToBitmap()
        #disable_bookmark_bmp = clear_image(bookmark_im).ConvertToBitmap()
        disable_bookmark_bmp = wx.NullBitmap
        self.AddLabelTool(GUIFRAME_ID.BOOKMARK_ID, 'Bookmark', bookmark_bmp,
                   disable_bookmark_bmp, button_type,'Bookmark')
        self.AddSeparator()
        zoom_in_im = GUIFRAME_ICON.ZOOM_IN_ICON
        zoom_in_im.Rescale(tbar_size[0], tbar_size[1], wx.IMAGE_QUALITY_HIGH)
        zoom_in_bmp = zoom_in_im.ConvertToBitmap()
        #disable_zoom_in_bmp = clear_image(zoom_in_im).ConvertToBitmap()
        disable_zoom_in_bmp = wx.NullBitmap
        self.AddLabelTool(GUIFRAME_ID.ZOOM_IN_ID, 'Zoom In', zoom_in_bmp,
                   disable_zoom_in_bmp, button_type,'Zoom In')
        self.AddSeparator()
        zoom_out_im = GUIFRAME_ICON.ZOOM_OUT_ICON
        zoom_out_im.Rescale(tbar_size[0], tbar_size[1], wx.IMAGE_QUALITY_HIGH)
        zoom_out_bmp = zoom_out_im.ConvertToBitmap()
        #disable_zoom_out_bmp = clear_image(zoom_out_im).ConvertToBitmap()
        disable_zoom_out_bmp = wx.NullBitmap
        self.AddLabelTool(GUIFRAME_ID.ZOOM_OUT_ID, 'Zoom Out', zoom_out_bmp,
                   disable_zoom_out_bmp, button_type,'Zoom Out')
        self.AddSeparator()
        zoom_im = GUIFRAME_ICON.ZOOM_ICON
        zoom_im.Rescale(tbar_size[0], tbar_size[1], wx.IMAGE_QUALITY_HIGH)
        zoom_bmp = zoom_im.ConvertToBitmap()
        #disable_zoom_bmp = clear_image(zoom_im).ConvertToBitmap()
        disable_zoom_bmp = wx.NullBitmap
        self.AddLabelTool(GUIFRAME_ID.ZOOM_ID, 'Zoom', zoom_bmp,
                   disable_zoom_bmp, button_type,'Zoom In')
        self.AddSeparator()
        drag_im = GUIFRAME_ICON.DRAG_ICON
        drag_im.Rescale(tbar_size[0], tbar_size[1], wx.IMAGE_QUALITY_HIGH)
        drag_bmp = drag_im.ConvertToBitmap()
        #disable_drag_bmp = clear_image(drag_im).ConvertToBitmap()
        disable_drag_bmp = wx.NullBitmap
        self.AddLabelTool(GUIFRAME_ID.DRAG_ID, 'Drag', drag_bmp,
                   disable_drag_bmp, button_type,'Drag')
        self.AddSeparator()
        report_im = GUIFRAME_ICON.REPORT_ICON
        report_im.Rescale(tbar_size[0], tbar_size[1], wx.IMAGE_QUALITY_HIGH)
        report_bmp = report_im.ConvertToBitmap()
        #disable_report_bmp = clear_image(report_im).ConvertToBitmap()<commit_msg>add button reset<commit_after>
import wx
import os
from wx import ToolBar as Tbar


from sans.guiframe.gui_style import GUIFRAME_ID
from sans.guiframe.gui_style import GUIFRAME_ICON


def clear_image(image):
    w, h = image.GetSize()
    factor = 155
    compress = lambda x: int(x * factor/255.) + factor
    for y in range(h):
        for x in range(w):
            grey = compress(image.GetGreen(x, y))
            image.SetRGB(x, y, grey, grey, grey)
    if image.HasAlpha():
        image.ConvertAlphaToMask()
    return image

class GUIToolBar(Tbar):
    """
    Implement toolbar for guiframe
    """
    def __init__(self, parent,  *args, **kwds):
        Tbar.__init__(self, parent,  *args, **kwds)
        self.parent = parent
        self.do_layout()
        self.on_bind_button()
       
    def do_layout(self):
        """
        """
        tbar_size = (22, 22)
        button_type =  wx.ITEM_NORMAL
        save_im = GUIFRAME_ICON.SAVE_ICON
        save_im.Rescale(tbar_size[0], tbar_size[1], wx.IMAGE_QUALITY_HIGH)
        save_bmp = save_im.ConvertToBitmap()
        #disable_save_bmp = clear_image(save_im).ConvertToBitmap()
        disable_save_bmp = wx.NullBitmap
        self.AddLabelTool(GUIFRAME_ID.SAVE_ID, 'Save', save_bmp, 
                          disable_save_bmp,button_type, shortHelp='Save')
        self.AddSeparator()
        bookmark_im = GUIFRAME_ICON.BOOKMARK_ICON
        bookmark_im.Rescale(tbar_size[0], tbar_size[1], wx.IMAGE_QUALITY_HIGH)
        bookmark_bmp = bookmark_im.ConvertToBitmap()
        #disable_bookmark_bmp = clear_image(bookmark_im).ConvertToBitmap()
        disable_bookmark_bmp = wx.NullBitmap
        self.AddLabelTool(GUIFRAME_ID.BOOKMARK_ID, 'Bookmark', bookmark_bmp,
                   disable_bookmark_bmp, button_type,'Bookmark')
        self.AddSeparator()
        zoom_in_im = GUIFRAME_ICON.ZOOM_IN_ICON
        zoom_in_im.Rescale(tbar_size[0], tbar_size[1], wx.IMAGE_QUALITY_HIGH)
        zoom_in_bmp = zoom_in_im.ConvertToBitmap()
        #disable_zoom_in_bmp = clear_image(zoom_in_im).ConvertToBitmap()
        disable_zoom_in_bmp = wx.NullBitmap
        self.AddLabelTool(GUIFRAME_ID.ZOOM_IN_ID, 'Zoom In', zoom_in_bmp,
                   disable_zoom_in_bmp, button_type,'Zoom In')
        self.AddSeparator()
        zoom_out_im = GUIFRAME_ICON.ZOOM_OUT_ICON
        zoom_out_im.Rescale(tbar_size[0], tbar_size[1], wx.IMAGE_QUALITY_HIGH)
        zoom_out_bmp = zoom_out_im.ConvertToBitmap()
        #disable_zoom_out_bmp = clear_image(zoom_out_im).ConvertToBitmap()
        disable_zoom_out_bmp = wx.NullBitmap
        self.AddLabelTool(GUIFRAME_ID.ZOOM_OUT_ID, 'Zoom Out', zoom_out_bmp,
                   disable_zoom_out_bmp, button_type,'Zoom Out')
        self.AddSeparator()
        zoom_im = GUIFRAME_ICON.ZOOM_ICON
        zoom_im.Rescale(tbar_size[0], tbar_size[1], wx.IMAGE_QUALITY_HIGH)
        zoom_bmp = zoom_im.ConvertToBitmap()
        #disable_zoom_bmp = clear_image(zoom_im).ConvertToBitmap()
        disable_zoom_bmp = wx.NullBitmap
        self.AddLabelTool(GUIFRAME_ID.ZOOM_ID, 'Zoom', zoom_bmp,
                   disable_zoom_bmp, button_type,'Zoom In')
        self.AddSeparator()
        reset_im = GUIFRAME_ICON.RESET_ICON
        reset_im.Rescale(tbar_size[0], tbar_size[1], wx.IMAGE_QUALITY_HIGH)
        reset_bmp = reset_im.ConvertToBitmap()
        #disable_reset_bmp = clear_image(reset_im).ConvertToBitmap()
        disable_reset_bmp = wx.NullBitmap
        self.AddLabelTool(GUIFRAME_ID.RESET_ID, 'Reset', reset_bmp,
                   disable_reset_bmp, button_type,'Reset In')
        self.AddSeparator()
        drag_im = GUIFRAME_ICON.DRAG_ICON
        drag_im.Rescale(tbar_size[0], tbar_size[1], wx.IMAGE_QUALITY_HIGH)
        drag_bmp = drag_im.ConvertToBitmap()
        #disable_drag_bmp = clear_image(drag_im).ConvertToBitmap()
        disable_drag_bmp = wx.NullBitmap
        self.AddLabelTool(GUIFRAME_ID.DRAG_ID, 'Drag', drag_bmp,
                   disable_drag_bmp, button_type,'Drag')
        self.AddSeparator()
        report_im = GUIFRAME_ICON.REPORT_ICON
        report_im.Rescale(tbar_size[0], tbar_size[1], wx.IMAGE_QUALITY_HIGH)
        report_bmp = report_im.ConvertToBitmap()
        #disable_report_bmp = clear_image(report_im).ConvertToBitmap()
{'fraction_non_alphanumeric': 0.09644044833107526, 'fraction_numerical': 0.00615839389087326, 'mean_word_length': 2.9901719901719903, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4703433', 'n_tokens_mistral': 2975, 'n_tokens_neox': 2902, 'n_words': 409}