Gatan | AMETEKSkip to Main Content
No options found

Text output examples

Python Script

Basic text output examples in DigitalMicrograph. By default, the output stream is sent to the Results window.

Preview

'''
Basic text output examples in DigitalMicrograph.
By default, the output stream is send to the Results window.
'''
import DigitalMicrograph as DM

# Clears the output results window
DM.ClearResults() 

# Standard print commands
print( 'Hello World.' )

print( 'Simple value:', 123.456 )

print( 'Some items listed:', end = "\n\t" )
print( "first", "second", "third", end = "\n\t" )
print( "first", "second", "third", sep=', ', end = "\n\n" )

print( 'Using a string literal:' )
for i in range (1,5):
    print( f'\tvalue:{i} squared = {i*i}')

print( '\nFormated string:\n\t second value = {1:3.1f} \n\t first value  = {0:3.4f}'.format( 12.34, 56.78 ) )

# The output stream can be redirected to other windows
DM.SetOutputTo(2)
print( 'Output to Debug window.' )
DM.SetOutputTo(1)
print( 'Output to Notes window.' )
DM.SetOutputTo(0)
print( 'Output to Results window.' )

# The results command will always output to the Results window
# but can only use a single, simple sring argument.
DM.SetOutputTo(1)
DM.Result( 'Always to Results window.' )
DM.SetOutputTo(0)