-
Notifications
You must be signed in to change notification settings - Fork 61
Reactive GUI #1572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reactive GUI #1572
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -232,6 +232,8 @@ def _update_table(self, params: dict[str, ArduPilotParameter], gui_complexity: s | |||||
| if self.parameter_editor.should_display_bitmask_parameter_editor_usage(param_name): | ||||||
| should_try_to_display_bitmask_parameter_editor_usage = True | ||||||
| self._grid_column_widgets(row_widgets, i, show_upload_column) | ||||||
| if i % 20 == 0: | ||||||
| self.view_port.update_idletasks() # yield to the event loop periodically to keep the UI responsive | ||||||
|
||||||
| self.view_port.update_idletasks() # yield to the event loop periodically to keep the UI responsive | |
| self.view_port.update() # process pending UI events periodically so the interface remains responsive during long renders |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -71,12 +71,6 @@ def on_frame_configure(self, _event) -> None: # noqa: ANN001 | |||||
| """Reset the scroll region to encompass the inner frame.""" | ||||||
| # Whenever the size of the frame changes, alter the scroll region respectively. | ||||||
| self.canvas.configure(scrollregion=self.canvas.bbox("all")) | ||||||
| # Calculate the bounding box for the scroll region, starting from the second row | ||||||
| # bbox = self.canvas.bbox("all") | ||||||
| # if bbox: | ||||||
| # # Adjust the bounding box to start from the second row | ||||||
| # bbox = (bbox[0], bbox[1] + self.canvas.winfo_reqheight(), bbox[2], bbox[3]) | ||||||
| # self.canvas.configure(scrollregion=bbox) | ||||||
|
|
||||||
| def on_canvas_configure(self, event: tk.Event) -> None: | ||||||
| """Reset the canvas window to encompass inner frame when required.""" | ||||||
|
|
@@ -86,7 +80,8 @@ def on_canvas_configure(self, event: tk.Event) -> None: | |||||
|
|
||||||
| def on_mouse_wheel(self, event: tk.Event) -> None: # cross platform scroll wheel event | ||||||
| canvas_height = self.canvas.winfo_height() | ||||||
| rows_height = self.canvas.bbox("all")[3] | ||||||
| bbox = self.canvas.bbox("all") | ||||||
| rows_height = bbox[3] if bbox is not None else 0 | ||||||
|
||||||
| rows_height = bbox[3] if bbox is not None else 0 | |
| rows_height = (bbox[3] - bbox[1]) if bbox is not None else 0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1703,6 +1703,33 @@ def test_update_table_creates_add_button_with_tooltip(self, parameter_editor_tab | |
| tooltip_call_args = mock_tooltip.call_args[0] | ||
| assert "Add a parameter to the test_file.param file" in tooltip_call_args[1] | ||
|
|
||
| def test_update_table_yields_to_event_loop_every_twenty_rows(self, parameter_editor_table) -> None: | ||
| """ | ||
| Table update yields to the event loop periodically during large renders. | ||
|
|
||
| GIVEN: More than twenty parameters to render | ||
| WHEN: The table is updated | ||
| THEN: The viewport idletasks are processed every twentieth row | ||
| """ | ||
| params = { | ||
| f"TEST_PARAM_{index:02d}": create_mock_data_model_ardupilot_parameter( | ||
| name=f"TEST_PARAM_{index:02d}", value=float(index) | ||
| ) | ||
| for index in range(1, 46) | ||
| } | ||
|
|
||
| with ( | ||
| patch.object(parameter_editor_table, "_create_column_widgets", return_value=[MagicMock() for _ in range(7)]), | ||
|
||
| patch.object(parameter_editor_table, "_grid_column_widgets"), | ||
| patch.object(parameter_editor_table, "_configure_table_columns"), | ||
| patch.object(parameter_editor_table.view_port, "update_idletasks") as mock_update_idletasks, | ||
| patch("tkinter.ttk.Button"), | ||
| patch("ardupilot_methodic_configurator.frontend_tkinter_parameter_editor_table.show_tooltip"), | ||
| ): | ||
| parameter_editor_table._update_table(params, "simple") | ||
|
|
||
| assert mock_update_idletasks.call_count == 2 | ||
|
|
||
| def test_create_flightcontroller_value_sets_correct_background_colors(self, parameter_editor_table) -> None: # pylint: disable=too-many-statements # noqa: PLR0915 | ||
| """ | ||
| Flight controller value labels display with appropriate background colors based on parameter state. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling
update_idletasks()every 5 components can become a noticeable overhead for large component sets. Consider using a larger batch size and/or throttling based on elapsed time (e.g., yield every N ms) so performance scales better while still maintaining responsiveness.