<commit_before>'''
Dialog for obtaining scaling information from the user.

This package was developed by the Thermal Modeling and Analysis Project
(TMAP) of the National Oceanographic and Atmospheric Administration's (NOAA)
Pacific Marine Environmental Lab (PMEL).
'''

import pygtk
pygtk.require('2.0')
import gtk

class PyGtkScaleDialog(gtk.Dialog):
    '''
    Dialog for obtaining scaling information from the user.
    Validates that the resulting width and height values
    are not smaller than the specified minimums.
    '''

    def __init__(self, title, message, scale, width, height,
                 minwidth, minheight, dpis, parent):
        '''
        Creates a scaling dialog with title as the window title,
        message as the dialog message, and scale as the current
        scaling value which gives a pixmap of size width and
        height.  The minimum acceptable width and heights are
        given by minwidth and minheight.  Values are assumed to
        be in units of pixels, and dpis is a two-tuple of floats
        giving the number of pixels per inch
        '''
        super(PyGtkScaleDialog, self).__init__( title, parent,
                        gtk.DIALOG_MODAL,
                        (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                         gtk.STOCK_OK, gtk.RESPONSE_ACCEPT) )
        self.__scale = float(scale)
        self.__pixwidth = float(width)
        self.__inchwidth = float(width) / float(dpis[0])
        self.__pixheight = float(height)
        self.__inchheight = float(height) / float(dpis[1])
        self.__minpixwidth = int(minwidth)
        self.__minpixheight = int(minheight)
        self.FLTSTR_FORMAT = "%#.2f"
        # table layout
        dlgtable = gtk.Table(6, 5, False)
        dlgtable.set_row_spacings(4)
        dlgtable.set_col_spacings(4)
        # put the table in the central area of the dialog
        dlgtable.set_border_width(4)
        self.vbox.pack_start(dlgtable)
        # first table row - centered message        
        msglabel = gtk.Label(message)
        msglabel.set_alignment(0.5, 0.5)
        dlgtable.attach(msglabel, 0, 5, 0, 1)
        # second table row - scale label and text editor
        scalelabel = gtk.Label("Scale:")
        scalelabel.set_alignment(0.0, 0.5)
        dlgtable.attach(scalelabel, 0, 1, 1, 2)
        self.__scaleedit = gtk.Entry()
        self.__scaleedit.set_editable(True)
        self.__scaleedit.set_text( self.FLTSTR_FORMAT % self.__scale )
        dlgtable.attach(self.__scaleedit, 1, 5, 1, 2)
        # third table row - width labels
        widthbegin = gtk.Label("Width:")
        widthbegin.set_alignment(0.0, 0.5)
        dlgtable.attach(widthbegin, 0, 1, 2, 3)
        self.__pixwidthlabel = gtk.Label( str(int(self.__pixwidth + 0.5)) )
        dlgtable.attach(self.__pixwidthlabel, 1, 2, 2, 3)
        widthmiddle = gtk.Label("pixels, or")
        dlgtable.attach(widthmiddle, 2, 3, 2, 3)
        self.__inchwidthlabel = gtk.Label( self.FLTSTR_FORMAT % self.__inchwidth )
        dlgtable.attach(self.__inchwidthlabel, 3, 4, 2, 3)
        widthend = gtk.Label("inches on the screen")
        dlgtable.attach(widthend, 4, 5, 2, 3)
        # fourth table row - min width info label
        minwidthlabel = gtk.Label( "(must not be less than %d pixels)" % \
                                   self.__minpixwidth )
        dlgtable.attach(minwidthlabel, 1, 5, 3, 4)
        # fifth table row - height labels
        heightbegin = gtk.Label("Height:")
        heightbegin.set_alignment(0.0, 0.5)
        dlgtable.attach(heightbegin, 0, 1, 4, 5)
        self.__pixheightlabel = gtk.Label( str(int(self.__pixheight + 0.5)) )
        dlgtable.attach(self.__pixheightlabel, 1, 2, 4, 5)
        heightmiddle = gtk.Label("pixels, or")
        dlgtable.attach(heightmiddle, 2, 3, 4, 5)
        self.__inchheightlabel = gtk.Label( self.FLTSTR_FORMAT % self.__inchheight )
        dlgtable.attach(self.__inchheightlabel, 3, 4, 4, 5)
        heightend = gtk.Label("inches on the screen")
        dlgtable.attach(heightend, 4, 5, 4, 5)
        # sixth table row - min height info label
        minheightlabel = gtk.Label( "(must not be less than %d pixels)" % \
                                   self.__minpixheight )
        dlgtable.attach(minheightlabel, 1, 5, 5, 6)
        # "show" the table and everything in it
        dlgtable.show_all()
        # set the default button
        okbutton = self.get_widget_for_response(gtk.RESPONSE_ACCEPT)
        okbutton.set_flags(gtk.CAN_DEFAULT)
        self.set_default(okbutton)
        # select all the text in the text edit
        self.__scaleedit.select_region(0, -1)
        # update all the label values when the scaling value changes
        self.__scaleedit.connect("changed", self.updateValues, None)       
<commit_msg>Use older and simpler method for setting the default button<commit_after>'''
Dialog for obtaining scaling information from the user.

This package was developed by the Thermal Modeling and Analysis Project
(TMAP) of the National Oceanographic and Atmospheric Administration's (NOAA)
Pacific Marine Environmental Lab (PMEL).
'''

import pygtk
pygtk.require('2.0')
import gtk

class PyGtkScaleDialog(gtk.Dialog):
    '''
    Dialog for obtaining scaling information from the user.
    Validates that the resulting width and height values
    are not smaller than the specified minimums.
    '''

    def __init__(self, title, message, scale, width, height,
                 minwidth, minheight, dpis, parent):
        '''
        Creates a scaling dialog with title as the window title,
        message as the dialog message, and scale as the current
        scaling value which gives a pixmap of size width and
        height.  The minimum acceptable width and heights are
        given by minwidth and minheight.  Values are assumed to
        be in units of pixels, and dpis is a two-tuple of floats
        giving the number of pixels per inch
        '''
        super(PyGtkScaleDialog, self).__init__( title, parent,
                        gtk.DIALOG_MODAL,
                        (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                         gtk.STOCK_OK, gtk.RESPONSE_ACCEPT) )
        self.__scale = float(scale)
        self.__pixwidth = float(width)
        self.__inchwidth = float(width) / float(dpis[0])
        self.__pixheight = float(height)
        self.__inchheight = float(height) / float(dpis[1])
        self.__minpixwidth = int(minwidth)
        self.__minpixheight = int(minheight)
        self.FLTSTR_FORMAT = "%#.2f"
        # table layout
        dlgtable = gtk.Table(6, 5, False)
        dlgtable.set_row_spacings(4)
        dlgtable.set_col_spacings(4)
        # put the table in the central area of the dialog
        dlgtable.set_border_width(4)
        self.vbox.pack_start(dlgtable)
        # first table row - centered message        
        msglabel = gtk.Label(message)
        msglabel.set_alignment(0.5, 0.5)
        dlgtable.attach(msglabel, 0, 5, 0, 1)
        # second table row - scale label and text editor
        scalelabel = gtk.Label("Scale:")
        scalelabel.set_alignment(0.0, 0.5)
        dlgtable.attach(scalelabel, 0, 1, 1, 2)
        self.__scaleedit = gtk.Entry()
        self.__scaleedit.set_editable(True)
        self.__scaleedit.set_text( self.FLTSTR_FORMAT % self.__scale )
        dlgtable.attach(self.__scaleedit, 1, 5, 1, 2)
        # third table row - width labels
        widthbegin = gtk.Label("Width:")
        widthbegin.set_alignment(0.0, 0.5)
        dlgtable.attach(widthbegin, 0, 1, 2, 3)
        self.__pixwidthlabel = gtk.Label( str(int(self.__pixwidth + 0.5)) )
        dlgtable.attach(self.__pixwidthlabel, 1, 2, 2, 3)
        widthmiddle = gtk.Label("pixels, or")
        dlgtable.attach(widthmiddle, 2, 3, 2, 3)
        self.__inchwidthlabel = gtk.Label( self.FLTSTR_FORMAT % self.__inchwidth )
        dlgtable.attach(self.__inchwidthlabel, 3, 4, 2, 3)
        widthend = gtk.Label("inches on the screen")
        dlgtable.attach(widthend, 4, 5, 2, 3)
        # fourth table row - min width info label
        minwidthlabel = gtk.Label( "(must not be less than %d pixels)" % \
                                   self.__minpixwidth )
        dlgtable.attach(minwidthlabel, 1, 5, 3, 4)
        # fifth table row - height labels
        heightbegin = gtk.Label("Height:")
        heightbegin.set_alignment(0.0, 0.5)
        dlgtable.attach(heightbegin, 0, 1, 4, 5)
        self.__pixheightlabel = gtk.Label( str(int(self.__pixheight + 0.5)) )
        dlgtable.attach(self.__pixheightlabel, 1, 2, 4, 5)
        heightmiddle = gtk.Label("pixels, or")
        dlgtable.attach(heightmiddle, 2, 3, 4, 5)
        self.__inchheightlabel = gtk.Label( self.FLTSTR_FORMAT % self.__inchheight )
        dlgtable.attach(self.__inchheightlabel, 3, 4, 4, 5)
        heightend = gtk.Label("inches on the screen")
        dlgtable.attach(heightend, 4, 5, 4, 5)
        # sixth table row - min height info label
        minheightlabel = gtk.Label( "(must not be less than %d pixels)" % \
                                   self.__minpixheight )
        dlgtable.attach(minheightlabel, 1, 5, 5, 6)
        # "show" the table and everything in it
        dlgtable.show_all()
        # set the default button
        self.set_default_response(gtk.RESPONSE_ACCEPT)
        # select all the text in the text edit
        self.__scaleedit.select_region(0, -1)
        # update all the label values when the scaling value changes
        self.__scaleedit.connect("changed", self.updateValues, None)       

{'fraction_non_alphanumeric': 0.09483028720626632, 'fraction_numerical': 0.019216710182767625, 'mean_word_length': 2.38255033557047, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3717296', 'n_tokens_mistral': 3080, 'n_tokens_neox': 2886, 'n_words': 832}