E notation in textboxes with data binding

So this was a fun learning experience:

The issue is that at a certain point in python when float numbers are small enough or big enough, it automatically converts them to scientific notation. So far as I can tell from my research, you have to manually mangle the float as a string with formatting to have it look correctly:

I did this by adding an event handler when data bindings refresh to format any floats that include positive or negative scientific notation.


    def from_scientific_notation(self, number):
        number = float(number)
        num_str = str(number)
        if number < 1 and "e" in num_str:
            decimal_number = int(num_str.split("e")[-1]) * -1
            number = f"{number:.{decimal_number}f}"
            

        if not isinstance(number, str) and number >= 1:
            number = int(number)

        return number

    def form_refreshing_data_bindings(self, **event_args):
        """This method is called when refresh_data_bindings is called"""
        self.item["textbox_number"] = self.from_scientific_notation(self.item["textbox_number"])