Adding History Feature to Calculator #34 #47
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addition of Operation History in Calculadora.py:
In this update, I added a "History" submenu to the main menu of the calculator to allow users to view and manage their operation history.
This commit introduces two new methods: _show_history and _clear_history.
In _show_history, a new window (history_window) is created to display the calculation history.
The window is configured with a title, background color, and dimensions.
Entries from the self.history list, representing the calculation history, are iterated over, and labels are created for each entry.
These labels display the operation performed and its result.
Only the last 10 entries of the history are displayed
In _clear_history, the calculation history (self.history) is cleared, effectively removing all previous calculations from memory.
These changes enhance the functionality of the application by providing users with the ability to view their past calculations and clear the history.
In the _create_menu function, which is responsible for creating and configuring the main menu of the application:
method, which will display the operation history. The "Limpar Histórico" command calls the _clear_history method, which
will clear the operation history.
Users can now easily review their calculation history and have the option to clear it.