Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
name: Pull Request
about: Create a pull request to help us improve
title: Synced tables
assignees: ''
Description:
Technically Dear ImGui allows the caller to use the same item ID for two (or more) different item - I bet it started as a side effect but turned out to be useful in some cases. In particular, items with the same ID share whatever state is stored on ImGui side. In case of tables, this state includes column widths and probably some other data. That is, when two tables are assigned the same ID, they get somewhat "synced" and act as pieces of a single table. This can be useful e.g. when one wants to insert custom content between rows of a table - think of expanding rows or messages that occupy the entire table width. The feature is pretty stable, mentioned in a number of tickets and is even demonstrated in ImGui demo.
DearPyGui uses a
ScopedIDinmvTable::draw(), which makes every table ID unique in ImGui. This PR removes theScopedIDand allows two tables to have the same ID - for example, you can pass it in the label (which the table won't display anyway) as"###my-table-id". Remember to also setuse_internal_labelto False so that DPG uses the label and not UUID to create ImGui ID:The PR also adds a new container,
synced_tables, which makes it easier to create synced table instances. All tables that are immediate children of asynced_tablesitem share their state without the need to explicitly assign them the same ID. The following code snippet behaves just like the one above - notice howdpg.tabledoesn't use thatlabeltrick:Unfortunately there's no doc on this new feature, I hope to eventually add it... Maybe.
Concerning Areas:
None.