(widget)
return padx, pady
Get the total padding of a Tk widget, including its border.
Get the total padding of a Tk widget, including its border.
Get the total padding of a Tk widget including its border .
def get_widget_padding(widget):
    """Get the total padding of a Tk widget, including its border."""
    # TODO: use also in codecontext.py
    manager = widget.winfo_manager()
    if manager == 'pack':
        info = widget.pack_info()
    elif manager == 'grid':
        info = widget.grid_info()
    else:
        raise ValueError(f"Unsupported geometry manager: {manager}")

    # All values are passed through getint(), since some
    # values may be pixel objects, which can't simply be added to ints.
    padx = sum(map(widget.tk.getint, [
        info['padx'],
        widget.cget('padx'),
        widget.cget('border'),
    ]))
    pady = sum(map(widget.tk.getint, [
        info['pady'],
        widget.cget('pady'),
        widget.cget('border'),
    ]))
    return padx, pady
def get_widget_padding ( widget ) : # TODO: use also in codecontext.py manager = widget . winfo_manager ( ) if manager == 'pack' : info = widget . pack_info ( ) elif manager == 'grid' : info = widget . grid_info ( ) else : raise ValueError ( f"Unsupported geometry manager: {manager}" ) # All values are passed through getint(), since some # values may be pixel objects, which can't simply be added to ints. padx = sum ( map ( widget . tk . getint , [ info [ 'padx' ] , widget . cget ( 'padx' ) , widget . cget ( 'border' ) , ] ) ) pady = sum ( map ( widget . tk . getint , [ info [ 'pady' ] , widget . cget ( 'pady' ) , widget . cget ( 'border' ) , ] ) ) return padx , pady