sugarlabs / convert

Sugar units conversion activity
GNU General Public License v3.0
0 stars 6 forks source link

Removing spin buttons #21

Closed Aniket21mathur closed 5 years ago

Aniket21mathur commented 5 years ago

The spin buttons were not required as per the issue.

Instead of using spinButton used simple text entry with checks for integer inputs.

Fixes https://github.com/sugarlabs/convert/issues/14

Aniket21mathur commented 5 years ago

@quozl I used simple Gtk.Entry() in place of Gtk.SpinButton().So accordingly I made few changes based on few observations: 1)The input number or the number on the left hand side always had one decimal place so I fixed it to "1" or the decimal value of ".0". 2)There need to be a check for non integer entries so I used try and catch and always reset the value to 1.0 whenever a string is entered. Thanks! Please review.

quozl commented 5 years ago

Thanks. Reviewed. Comments;

Aniket21mathur commented 5 years ago

Agreed, made the suggested changes. Thanks :smile:

quozl commented 5 years ago

Thanks. Good progress. Reviewed. Comments;

Aniket21mathur commented 5 years ago

Thanks for reviewing, made the above changes. :smile:

quozl commented 5 years ago

Thanks. Nearly done. Reviewed. Comments on the user experience of value entry;

screenshot_ubb_2019-01-18_10 28 41

Aniket21mathur commented 5 years ago

Thanks for reviewing worked on the suggestions you made and pushed the changes :smile: .

quozl commented 5 years ago

It's getting complicated, isn't it? For some locales, a comma is a thousands separator, and for others it is a decimal point. Might it be better to place a call to float() inside an exception handler?

Aniket21mathur commented 5 years ago

It's getting complicated, isn't it? For some locales, a comma is a thousands separator, and for others it is a decimal point.

Now there is exactly one function where a comma is treated as a decimal point

def _flip(self, widget): active_combo1 = self.combo1.get_active() active_combo2 = self.combo2.get_active() self.combo1.set_active(active_combo2) self.combo2.set_active(active_combo1) value = float(self.label.get_text().split(' ~ ')[1].replace(',', '.')) self.value_entry.set_text(str(value)) self.call()

And after the above changes there is no longer need of this line

.replace(',', '.'))

to calculate value for _flip function as "," will already be handled by _update_label function.So there is no concept of commas as decimals in the code now. Thanks!

quozl commented 5 years ago

Thanks. Tested.