Calculator Module Reference

New in version 0.0.2.

Control the macOS Calculator application using JXA-like syntax.

Classes:

XACalculatorApplication(properties)

A class for managing and interacting with Calculator.app.

class PyXA.apps.Calculator.XACalculatorApplication(properties)[source]

Bases: XAApplication

A class for managing and interacting with Calculator.app.

New in version 0.0.2.

Methods:

clear_value()

Clears the current calculator output.

copy_value()

Copies the current value of the calculator result.

current_value()

Retrieves the current value of the calculator output.

input(sequence)

Inputs a sequence of numbers and operations into the calculator by mimicking button clicks.

open_about_panel()

Opens the "About Calculator" panel.

open_page_setup()

Opens the page setup dialog.

print_tape()

Opens the print tape dialog.

save_tape()

Opens the "save tape" dialog.

show_basic_calculator()

Switches the view to the basic calculator.

show_help()

Opens the Calculator help window.

show_paper_tape()

Opens the paper tape window.

show_programmer_calculator()

Switches the view to the programmer calculator.

show_scientific_calculator()

Switches the view to the scientific calculator.

toggle_RPN_mode()

Toggles Reverse Polish Notation.

toggle_thousands_separators()

Toggles whether comma separators are shown at thousand intervals.

clear_value()[source]

Clears the current calculator output. Mimics clicking the “C” (clear) button.

New in version 0.0.2.

copy_value()[source]

Copies the current value of the calculator result. Mimics clicking Edit->Copy.

New in version 0.0.2.

current_value() float[source]

Retrieves the current value of the calculator output.

Returns:

The calculator’s current displayed value

Return type:

float

New in version 0.0.2.

input(sequence: str)[source]

Inputs a sequence of numbers and operations into the calculator by mimicking button clicks.

This method does not obtain the result of the input. For that, use current_value().

The sequence should be a continuous string (no spaces). The valid characters are numbers 0-9, +, -, *, /, %, ~, =, and c. Their meanings are as follows:

  • +, -, *, and / correspond to their usual operation buttons.

  • % designates the percentage button.

  • ~ corresponds to the negation button.

  • = represents the equals button.

  • c denotes the clear button.

Parameters:

sequence (str) – The sequence of numbers and operations to execute.

Example:

>>> import PyXA
>>> app = PyXA.Application("Calculator")
>>> app.input("c2*3.14*5*5=")
34.54

New in version 0.0.2.

open_about_panel()[source]

Opens the “About Calculator” panel. Mimics clicking File->About Calculator.

New in version 0.0.2.

open_page_setup()[source]

Opens the page setup dialog. Mimics clicking File->Page Setup…

New in version 0.0.2.

print_tape()[source]

Opens the print tape dialog. Mimics clicking File->Print Tape…

New in version 0.0.2.

save_tape()[source]

Opens the “save tape” dialog. Mimics clicking File->Save Tape As…

New in version 0.0.2.

show_basic_calculator()[source]

Switches the view to the basic calculator. Mimics clicking View->Basic.

New in version 0.0.2.

show_help()[source]

Opens the Calculator help window. Mimics clicking Help->Calculator Help.add()

New in version 0.0.2.

show_paper_tape()[source]

Opens the paper tape window. Mimics clicking Window->Show Paper Tape.

New in version 0.0.2.

show_programmer_calculator()[source]

Switches the view to the programmer calculator. Mimics clicking View->Programmer.

New in version 0.0.2.

show_scientific_calculator()[source]

Switches the view to the scientific calculator. Mimics clicking View->Scientific.

New in version 0.0.2.

toggle_RPN_mode()[source]

Toggles Reverse Polish Notation. Mimics clicking View->RPN Mode.

New in version 0.0.2.

toggle_thousands_separators()[source]

Toggles whether comma separators are shown at thousand intervals. Mimics clicking View->Show Thousands Separators.

New in version 0.0.2.