Calculator Module Reference
New in version 0.0.2.
Control the macOS Calculator application using JXA-like syntax.
Classes:
|
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:
Clears the current calculator output.
Copies the current value of the calculator result.
Retrieves the current value of the calculator output.
input
(sequence)Inputs a sequence of numbers and operations into the calculator by mimicking button clicks.
Opens the "About Calculator" panel.
Opens the page setup dialog.
Opens the print tape dialog.
Opens the "save tape" dialog.
Switches the view to the basic calculator.
Opens the Calculator help window.
Opens the paper tape window.
Switches the view to the programmer calculator.
Switches the view to the scientific calculator.
Toggles Reverse Polish Notation.
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.