Closed Aniket21mathur closed 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.
Thanks. Reviewed. Comments;
self.adjustment
required any longer? You removed the last use of the variable.Gtk.Editable.signals.insert_text
to detect and ignore text that is not numeric? I've checked; we use insert-text
in a few other activities, but none of them stop the signal emission as the documentation suggests.Agreed, made the suggested changes. Thanks :smile:
Thanks. Good progress. Reviewed. Comments;
float()
call inside an exception handler in the insert-text callback,self.spin
is no longer a good name for the variable that references a Gtk.Entry widget, can you think of a better name?self.spin
is used elsewhere, see the set_value
, perhaps it should change,_cb
, and prefix with _
when the callback won't be used by any other code, but the prevailing style in this activity is underscore without _cb
suffix; please either use the prevailing style or fix all the callback function names in a separate patch and place them before your patches here,Thanks for reviewing, made the above changes. :smile:
Thanks. Nearly done. Reviewed. Comments on the user experience of value entry;
ValueError: invalid literal for float(): 1,000
,ValueError: invalid literal for float(): 12-45
,Thanks for reviewing worked on the suggestions you made and pushed the changes :smile: .
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?
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!
Thanks. Tested.
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