Having some trouble with: from kivymd.uix.datatables import MDDataTable: ZeroDivisionError: float division by zero

133 views
Skip to first unread message

Gary Kuipers

unread,
Apr 19, 2023, 8:40:43 AM4/19/23
to Kivy users support
Having some trouble with: from kivymd.uix.datatables import MDDataTable

One is that it does not render the table it receives. It produces this error (as can be seen below).
Traceback (most recent call last):
  File "/home/gary/PycharmProjects/YSI_Read/test_tables/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/manager/arm64-v8a/kivy/core/window/__init__.py", line 1630, in on_draw
ZeroDivisionError: float division by zero
ZeroDivisionError: float division by zero

I do not know if this causes the problem as I have seen it when the does render. This is also confusing because the render is a hit of miss thing.

The second problem is that when it does render it takes about 15 seconds from the time the data is received and the data becomes avaliable on the screen

I think the probem is in my approach o building the table and I could use some help please.



    def send_json_on_success(self, req, res):
        self.log(4, f"Sender: entering send_json_on_success with res={res}", False)
        self.counter_stop()
        print(f"Sender: entering send_json_on_success: kk2")
        self.root_widget.ids.status.text = 'ok'
        print(f"Sender: entering send_json_on_success: kk3")
        response = json.loads(res)
        print(f"send_json_on_success: response={response}")
        self.table_data = response
        print(f"send_json_on_success: self.table_data={self.table_data}")
        self.main.make_table_widget(self.table_data)
        print(f"Sender: entering send_json_on_success: kk4")

This is the construction of the table:
    def make_table_widget(self, rows):
        self.table_area.clear_widgets()   # If a data table exists, delete the datatable widget
        self.table = MDDataTable(         # Elliot: Create a new datatable with the received dat
            pos_hint={'center_x': 0.5, 'center_y': 0.5},
            size_hint=(1, 1),
            check=False,
            use_pagination=True,
            rows_num=10,
            pagination_menu_height='180dp',
            pagination_menu_pos="auto",
            background_color=[1, 0, 0, 0.5],  # does not work
            column_data=[
                ("", dp(1)),
                ("Cuando", dp(30), self.sort_on_datetime),
                ("U", dp(12), self.sort_on_location),
                ("O", dp(12), self.sort_on_do),
                ("%", dp(12), self.sort_on_pct),
                ("T", dp(12), self.sort_on_temp)
            ],
            row_data=rows,
            sorted_on="Cuando",
            sorted_order="DSC",
        )
        self.table.bind(on_row_press=self.on_row_press)
        self.table.bind(on_check_press=self.on_check_press)
        self.table_area.add_widget(self.table)  # Elliot: Add the datatable to the widget tree


04-19 05:50:57.143  7448  7499 I python  : 4:Sender: entering send_json_on_success with res=[["", "04-18 16:11:39", "p5", "  5.83", " 73.70", " 29.00"], ["", "04-18 16:08:25", "p4", "      ", "      ", "      "], ["", "04-18 16:03:57", "p3", "  9.35", "124.70", " 29.00"], ["", "04-18 16:00:53", "p2", "  3.82", " 51.90", " 30.10"], ["", "04-18 15:58:16", "p1", "  7.18", " 97.90", " 30.10"], ["", "04-18 15:57:07", "NULL", "      ", "      ", "      "], ["", "04-18 15:56:42", "NULL", "      ", "      ", "      "], ["", "04-18 07:14:52", "p5", "  1.99", " 26.00", " 28.00"], ["", "04-18 07:11:30", "p4", "  1.75", " 22.80", " 27.60"], ["", "04-18 07:07:06", "p3", "  5.39", " 68.90", " 26.60"]]
04-19 05:50:57.143  7448  7499 I python  : Sender: counter_stop: self.counter=3
04-19 05:50:57.144  7448  7499 I python  : Sender: counter_stop: kk2
04-19 05:50:57.144  7448  7499 I python  : Sender: entering send_json_on_success: kk2
04-19 05:50:57.144  7448  7499 I python  : Sender: entering send_json_on_success: kk3
04-19 05:50:57.144  7448  7499 I python  : send_json_on_success: response=[['', '04-18 16:11:39', 'p5', '  5.83', ' 73.70', ' 29.00'], ['', '04-18 16:08:25', 'p4', '      ', '      ', '      '], ['', '04-18 16:03:57', 'p3', '  9.35', '124.70', ' 29.00'], ['', '04-18 16:00:53', 'p2', '  3.82', ' 51.90', ' 30.10'], ['', '04-18 15:58:16', 'p1', '  7.18', ' 97.90', ' 30.10'], ['', '04-18 15:57:07', 'NULL', '      ', '      ', '      '], ['', '04-18 15:56:42', 'NULL', '      ', '      ', '      '], ['', '04-18 07:14:52', 'p5', '  1.99', ' 26.00', ' 28.00'], ['', '04-18 07:11:30', 'p4', '  1.75', ' 22.80', ' 27.60'], ['', '04-18 07:07:06', 'p3', '  5.39', ' 68.90', ' 26.60']]
04-19 05:50:57.144  7448  7499 I python  : send_json_on_success: self.table_data=[['', '04-18 16:11:39', 'p5', '  5.83', ' 73.70', ' 29.00'], ['', '04-18 16:08:25', 'p4', '      ', '      ', '      '], ['', '04-18 16:03:57', 'p3', '  9.35', '124.70', ' 29.00'], ['', '04-18 16:00:53', 'p2', '  3.82', ' 51.90', ' 30.10'], ['', '04-18 15:58:16', 'p1', '  7.18', ' 97.90', ' 30.10'], ['', '04-18 15:57:07', 'NULL', '      ', '      ', '      '], ['', '04-18 15:56:42', 'NULL', '      ', '      ', '      '], ['', '04-18 07:14:52', 'p5', '  1.99', ' 26.00', ' 28.00'], ['', '04-18 07:11:30', 'p4', '  1.75', ' 22.80', ' 27.60'], ['', '04-18 07:07:06', 'p3', '  5.39', ' 68.90', ' 26.60']]
04-19 05:50:57.370  7448  7499 I python  : Sender: entering send_json_on_success: kk4
04-19 05:50:57.370  7448  7499 I python  : 4:Sender: entering send_json_on_success with res={"id": 1, "action": "remove_log_data"}
04-19 05:50:57.370  7448  7499 I python  : Sender: counter_stop: self.counter=3
04-19 05:50:57.370  7448  7499 I python  : Sender: counter_stop: kk2
04-19 05:50:57.370  7448  7499 I python  : Sender: entering send_json_on_success: kk2
04-19 05:50:57.370  7448  7499 I python  : Sender: entering send_json_on_success: kk3
04-19 05:50:57.371  7448  7499 I python  : send_json_on_success: response={'id': 1, 'action': 'remove_log_data'}
04-19 05:50:57.371  7448  7499 I python  : send_json_on_success: self.table_data={'id': 1, 'action': 'remove_log_data'}
04-19 05:50:57.792  7448  7499 I python  : Sender: entering send_json_on_success: kk4
04-19 05:50:58.902  7448  7499 I python  :  ZeroDivisionError: float division by zero
04-19 05:50:58.903  7448  7499 I python  :  Exception ignored in: 'kivy.graphics.vertex_instructions.Line.prebuild_rounded_rectangle'
04-19 05:50:58.903  7448  7499 I python  :  Traceback (most recent call last):
04-19 05:50:58.903  7448  7499 I python  :    File "/home/gary/PycharmProjects/YSI_Read/test_tables/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/manager/arm64-v8a/kivy/core/window/__init__.py", line 1630, in on_draw
04-19 05:50:58.904  7448  7499 I python  :  ZeroDivisionError: float division by zero
04-19 05:50:58.911  7448  7499 I python  :  ZeroDivisionError: float division by zero
04-19 05:50:58.912  7448  7499 I python  :  Exception ignored in: 'kivy.graphics.vertex_instructions.Line.prebuild_rounded_rectangle'
04-19 05:50:58.912  7448  7499 I python  :  Traceback (most recent call last):
04-19 05:50:58.912  7448  7499 I python  :    File "/home/gary/PycharmProjects/YSI_Read/test_tables/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/manager/arm64-v8a/kivy/core/window/__init__.py", line 1630, in on_draw
04-19 05:50:58.913  7448  7499 I python  :  ZeroDivisionError: float division by zero
04-19 05:50:58.920  7448  7499 I python  :  ZeroDivisionError: float division by zero
04-19 05:50:58.920  7448  7499 I python  :  Exception ignored in: 'kivy.graphics.vertex_instructions.Line.prebuild_rounded_rectangle'
04-19 05:50:58.921  7448  7499 I python  :  Traceback (most recent call last):
04-19 05:50:58.921  7448  7499 I python  :    File "/home/gary/PycharmProjects/YSI_Read/test_tables/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/manager/arm64-v8a/kivy/core/window/__init__.py", line 1630, in on_draw
04-19 05:50:58.921  7448  7499 I python  :  ZeroDivisionError: float division by zero
04-19 05:50:58.929  7448  7499 I python  :  ZeroDivisionError: float division by zero
04-19 05:50:58.930  7448  7499 I python  :  Exception ignored in: 'kivy.graphics.vertex_instructions.Line.prebuild_rounded_rectangle'
04-19 05:50:58.930  7448  7499 I python  :  Traceback (most recent call last):

Elliot Garbus

unread,
Apr 19, 2023, 11:36:10 AM4/19/23
to kivy-...@googlegroups.com

Please share a minimal expectable program, with data, that demonstrates the issue.

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/6b62c732-8491-460c-a166-0d37eb026653n%40googlegroups.com.

 

Gary Kuipers

unread,
Apr 20, 2023, 8:15:09 AM4/20/23
to Kivy users support
HI Elliot:

The application is for android phone and the data comes from a server. Would you like that code or should I try to extract the code that will run in windows or linux?

Elliot Garbus

unread,
Apr 20, 2023, 11:37:40 AM4/20/23
to kivy-...@googlegroups.com

Capture the data and put it in a file or put the data in the code as a literal.  I’ll be running the code on Windows.

Reply all
Reply to author
Forward
0 new messages