Problem with tab spacing in Thonny vs. printout

5 views
Skip to first unread message

Jonathan Titus

unread,
Jan 12, 2026, 11:27:34 PMJan 12
to thonny
Here's a piece of code as it appears in Thonny.  The comments line up nicely.:

def adc_calc(): # recalculate dot, dash, space times for Morse
    global dot_period, dash_period, word_space
    adcValue = potentiometer.read_u16() # based on ADC 16-bit value
    if adcValue < 2000: # default if < 2000         
        adcValue = 2000
    dot_period = int(2176800/adcValue) # calc dot period
    dash_period = dot_period * 3         # calc dash = 3 dots
    word_space = dot_period * 7 # space between words = 7 dots
    letter_period = dot_period * 2 # add 2 more dot spaces at end of a letter
    return

When I print my code from within Thonny, tha tabs are not correct, as shown below:

def adc_calc(): # recalculate dot, dash, space times for Morse global dot_period, dash_period, word_space adcValue = potentiometer.read_u16() # based on ADC 16-bit value if adcValue < 2000: # default if < 2000          adcValue = 2000 dot_period = int(2176800/adcValue) # calc dot period dash_period = dot_period * 3 # calc dash = 3 dots word_space = dot_period * 7 # space between words = 7 dots letter_period = dot_period * 2 # add 2 more dot spaces at end of a letter

I want to transfer my code to a text editor such as Mac Pages or MS Word. How do I do that and keep the alignment of the comments as it appears in the Thonny window? I don't have this problem with other IDEs.

Any help appreciated.

Jon
Reply all
Reply to author
Forward
0 new messages