def __normalize(self, event=None):
        ew = event.widget
        contents = ew.get()
        icursor = ew.index(INSERT)
        if contents and contents[0] in 'xX' and self.__hexp.get():
            contents = '0' + contents
        # Figure out the contents in the current base.
        try:
            if self.__hexp.get():
                v = int(contents, 16)
            else:
                v = int(contents)
        except __HOLE__:
            v = None
        # If value is not legal, or empty, delete the last character inserted
        # and ring the bell.  Don't ring the bell if the field is empty (it'll
        # just equal zero.
        if v is None:
            pass
        elif v < 0 or v > 255:
            i = ew.index(INSERT)
            if event.char:
                contents = contents[:i-1] + contents[i:]
                icursor -= 1
            ew.bell()
        elif self.__hexp.get():
            contents = hex(v)[2:]
        else:
            contents = int(v)
        ew.delete(0, END)
        ew.insert(0, contents)
        ew.icursor(icursor)
dataset/ETHPy150Open Southpaw-TACTIC/TACTIC/src/context/client/tactic-api-python-4.0.api04/Tools/pynche/TypeinViewer.py/TypeinViewer.__normalize