(self, editwin)
Initialize settings for Squeezer.

        editwin is the shell's Editor window.
        self.text is the editor window text widget.
        self.base_test is the actual editor window Tk text widget, rather than
            EditorWindow's wrapper.
        self.expandingbuttons is the list of all buttons representing
            "squeezed" output.
Initialize settings for Squeezer.
Initialize settings for Squeezer .
def __init__(self, editwin):
        """Initialize settings for Squeezer.

        editwin is the shell's Editor window.
        self.text is the editor window text widget.
        self.base_test is the actual editor window Tk text widget, rather than
            EditorWindow's wrapper.
        self.expandingbuttons is the list of all buttons representing
            "squeezed" output.
        """
        self.editwin = editwin
        self.text = text = editwin.text

        # Get the base Text widget of the PyShell object, used to change
        # text before the iomark. PyShell deliberately disables changing
        # text before the iomark via its 'text' attribute, which is
        # actually a wrapper for the actual Text widget. Squeezer,
        # however, needs to make such changes.
        self.base_text = editwin.per.bottom

        # Twice the text widget's border width and internal padding;
        # pre-calculated here for the get_line_width() method.
        self.window_width_delta = 2 * (
            int(text.cget('border')) +
            int(text.cget('padx'))
        )

        self.expandingbuttons = []

        # Replace the PyShell instance's write method with a wrapper,
        # which inserts an ExpandingButton instead of a long text.
        def mywrite(s, tags=(), write=editwin.write):
            # Only auto-squeeze text which has just the "stdout" tag.
            if tags != "stdout":
                return write(s, tags)

            # Only auto-squeeze text with at least the minimum
            # configured number of lines.
            auto_squeeze_min_lines = self.auto_squeeze_min_lines
            # First, a very quick check to skip very short texts.
            if len(s) < auto_squeeze_min_lines:
                return write(s, tags)
            # Now the full line-count check.
            numoflines = self.count_lines(s)
            if numoflines < auto_squeeze_min_lines:
                return write(s, tags)

            # Create an ExpandingButton instance.
            expandingbutton = ExpandingButton(s, tags, numoflines, self)

            # Insert the ExpandingButton into the Text widget.
            text.mark_gravity("iomark", tk.RIGHT)
            text.window_create("iomark", window=expandingbutton,
                               padx=3, pady=5)
            text.see("iomark")
            text.update()
            text.mark_gravity("iomark", tk.LEFT)

            # Add the ExpandingButton to the Squeezer's list.
            self.expandingbuttons.append(expandingbutton)

        editwin.write = mywrite
def __init__ ( self , editwin ) : self . editwin = editwin self . text = text = editwin . text # Get the base Text widget of the PyShell object, used to change # text before the iomark. PyShell deliberately disables changing # text before the iomark via its 'text' attribute, which is # actually a wrapper for the actual Text widget. Squeezer, # however, needs to make such changes. self . base_text = editwin . per . bottom # Twice the text widget's border width and internal padding; # pre-calculated here for the get_line_width() method. self . window_width_delta = 2 * ( int ( text . cget ( 'border' ) ) + int ( text . cget ( 'padx' ) ) ) self . expandingbuttons = [ ] # Replace the PyShell instance's write method with a wrapper, # which inserts an ExpandingButton instead of a long text. def mywrite ( s , tags = ( ) , write = editwin . write ) : # Only auto-squeeze text which has just the "stdout" tag. if tags != "stdout" : return write ( s , tags ) # Only auto-squeeze text with at least the minimum # configured number of lines. auto_squeeze_min_lines = self . auto_squeeze_min_lines # First, a very quick check to skip very short texts. if len ( s ) < auto_squeeze_min_lines : return write ( s , tags ) # Now the full line-count check. numoflines = self . count_lines ( s ) if numoflines < auto_squeeze_min_lines : return write ( s , tags ) # Create an ExpandingButton instance. expandingbutton = ExpandingButton ( s , tags , numoflines , self ) # Insert the ExpandingButton into the Text widget. text . mark_gravity ( "iomark" , tk . RIGHT ) text . window_create ( "iomark" , window = expandingbutton , padx = 3 , pady = 5 ) text . see ( "iomark" ) text . update ( ) text . mark_gravity ( "iomark" , tk . LEFT ) # Add the ExpandingButton to the Squeezer's list. self . expandingbuttons . append ( expandingbutton ) editwin . write = mywrite