SargonCZ / laser-calculator

Simple calculator for optics and laser physics
MIT License
4 stars 1 forks source link

Add confirmation to clear history #6

Closed SargonCZ closed 2 years ago

SargonCZ commented 2 years ago

Problem description

There is a menu Option with two buttons, Show history and Clear history. The problem is, that the buttons are close one to another and it's easy to delete the history instead of showing it. This process is irreversible.

Possible solution

This can be easily fixed by doing the following:

  1. Ask for confirmation before deleting the history.
  2. (Optional) Add a separator between the two buttons.

Additional details

tkinter is used for the GUI, so you will need to use the documentation at tkdocs.com. You will be interested in the askyesno dialog (see here). The separator is described here. You will have to maybe add from tkinter import messagebox to the header.

The menu is created in the main class Calculator like this

https://github.com/SargonCZ/laser-calculator/blob/9675425834e7c90ecfbad657703596b9bdb31ffc/laser-calculator.py#L62-L70

Here, you will have to add the separator.

The Clear history is defined in this function:

https://github.com/SargonCZ/laser-calculator/blob/9675425834e7c90ecfbad657703596b9bdb31ffc/laser-calculator.py#L132-L139

You have to add the confirmation there.

PawelS23 commented 2 years ago

I will work on this part.

SargonCZ commented 2 years ago

@PawelS23 If you can, do it today. There are a lot of changes, so I would like to make a new release.