QtDictTagEditor#
Editable key-value tables for small dictionaries with search and typed values.
Screenshot#

Example#
Source: examples/qt_dict_tag_editor.py
"""QtDictTagEditor."""
from qtpy.QtWidgets import QApplication, QLabel, QVBoxLayout, QWidget
from qtextra.config import THEMES
from qtextra.widgets.qt_dict_tag_editor import QtDictTagEditor
app = QApplication([])
widget = QWidget()
THEMES.apply(widget)
layout = QVBoxLayout(widget)
layout.addWidget(QLabel("QtDictTagEditor"))
dict_editor = QtDictTagEditor()
dict_editor.set_items(
{
"name": "qtextra",
"retries": 3,
"threshold": 0.75,
"notes": None,
},
)
dict_editor.search_edit.setText("th")
layout.addWidget(dict_editor)
layout.addWidget(QLabel("Searchable table with typed values"))
secondary_editor = QtDictTagEditor()
secondary_editor.set_items(
{
"host": "localhost",
"port": 5432,
"timeout": 1.5,
"cache": None,
},
)
layout.addWidget(secondary_editor)
layout.addStretch()
widget.show()
app.exec_()
Notes#
- Useful for settings panels and metadata editors where the shape is small and dynamic.
API#
Qt Class#
Signals#
evt_item_added#
evt_item_removed#
evt_search_changed#
evt_value_text_changed#
evt_items_changed#
evt_key_text_changed#
Methods#
Editor for managing a searchable dictionary with typed values.
addCurrentItem = add_current_item
class-attribute
instance-attribute
#
addItem = add_item
class-attribute
instance-attribute
#
addItems = add_items
class-attribute
instance-attribute
#
clearItems = clear_items
class-attribute
instance-attribute
#
confirmClearItems = confirm_clear_items
class-attribute
instance-attribute
#
exportDict = export_dict
class-attribute
instance-attribute
#
getItems = items
class-attribute
instance-attribute
#
getValue = get_value
class-attribute
instance-attribute
#
hasItem = has_item
class-attribute
instance-attribute
#
removeItem = remove_item
class-attribute
instance-attribute
#
removeSelectedItem = remove_selected_item
class-attribute
instance-attribute
#
setItems = set_items
class-attribute
instance-attribute
#
add_current_item() -> bool
#
Add or update the current key/value input.
add_item(key: str, value: DictTagValue) -> bool
#
Add or replace a single item.
add_items(items: Mapping[str, DictTagValue]) -> list[str]
#
Add or replace multiple items and return affected keys.
clear_items(emit_signal: bool = True) -> None
#
Remove all items.
confirm_clear_items() -> bool
#
Ask for confirmation before clearing all items.
export_dict() -> dict[str, DictTagValue]
#
Export the current dictionary.
get_value(key: str) -> DictTagValue
#
Return the value for a key.
has_item(key: str) -> bool
#
Return whether a key is present.
items() -> dict[str, DictTagValue]
#
Return the current items in table order.
remove_item(key: str) -> bool
#
Remove an item by key.
remove_selected_item() -> bool
#
Remove the currently selected row.
set_items(items: Mapping[str, DictTagValue]) -> None
#
Replace all items.