Data¶
Widgets and classes for displaying and managing tabular and file data.
TableView¶
- class mytk.tableview.TableView(columns_labels, is_treetable=False, create_data_source=True)[source]¶
Bases:
BaseA table widget wrapping tkinter Treeview with data binding and editing support.
- exception DelegateError[source]¶
Bases:
ExceptionRaised when a delegate callback raises an unexpected error.
- exception WidgetNotYetCreatedError[source]¶
Bases:
ExceptionRaised when accessing widget properties before the widget is created.
- property columns¶
Return the list of column names.
- property displaycolumns¶
Return the list of currently displayed column names.
- property headings¶
Return the list of column heading labels.
- property columns_labels¶
Return a dict mapping column names to their heading labels.
- create_widget(master)[source]¶
Create the underlying Treeview widget within the given master container.
- source_data_changed(records)[source]¶
Update the widget to reflect changes in the data source records.
- source_data_added_or_updated(records)[source]¶
Insert new records or update existing ones in the widget.
- source_data_deleted(records)[source]¶
Remove widget items that are no longer present in the data source.
- record_to_formatted_widget_values(record)[source]¶
Convert a data record to a list of formatted strings for display.
- extract_record_from_formatted_widget_values()[source]¶
Extract a record from the formatted widget values (not implemented).
- item_modified(item_id, modified_record)[source]¶
Update a widget item and its backing data source record.
- get_column_name(column_id=None, display_column_number=None)[source]¶
Return the column name for a given column id or display column number.
- get_logical_column_id(column_name)[source]¶
Return the 0-based logical column index used to access item values.
- click_cell(item_id, column_name)[source]¶
Handle a single click on a specific cell, opening URLs if applicable.
- is_column_sorted(column_name)[source]¶
Return ‘<’ if sorted ascending, ‘>’ if descending, or None if unsorted.
- sorted_column(column_name=None, reverse=False)[source]¶
Return item identifiers sorted by the given column.
- sort_column(column_name=None, reverse=False)[source]¶
Sort the widget items in place by the given column.
- doubleclick_cell(item_id, column_name)[source]¶
Handle a double-click on a cell, entering edit mode if editable.
TabularData¶
- class mytk.tabulardata.PostponeChangeCalls(data_source)[source]¶
Bases:
objectContext manager that batches data change notifications until exit.
- class mytk.tabulardata.TabularData(tableview=None, delegate=None, required_fields=None)[source]¶
Bases:
BindableA data model for tabular records with field validation and persistence.
- exception MissingFieldError[source]¶
Bases:
ExceptionRaised when a required field is missing from a record.
- exception ExtraFieldError[source]¶
Bases:
ExceptionRaised when a record contains a field not in the required fields.
- exception UnrecognizedFileFormatError[source]¶
Bases:
ExceptionRaised when attempting to load a file with an unsupported format.
- get_field_property(field_name, property_name)[source]¶
Return a single property value for the given field.
- update_field_properties(field_name, new_properties)[source]¶
Merge new properties into the existing properties for a field.
- property record_count¶
Return the number of records.
- record_fields(internal=False)[source]¶
Return a sorted list of field names present across all records.
- remove_record(index_or_uuid)[source]¶
Remove and return the record at the given index or with the given UUID.
- insert_child_records(index, records, pid)[source]¶
Insert multiple records as children of the given parent UUID.
- insert_record(index, values, pid=None)[source]¶
Insert a record at the given index with an optional parent UUID.
- update_record(index_or_uuid, values)[source]¶
Update an existing record identified by index or UUID with new values.
- update_field(name, values)[source]¶
Update a field across all records with the given list of values.
- record_depth_level(uuid)[source]¶
Return the nesting depth of the record in the parent-child hierarchy.
- element(index_or_uuid, name)[source]¶
Return a single field value from the record at the given index or UUID.
- sorted_records_uuids(field, only_uuids=None, reverse=False)[source]¶
Return record UUIDs sorted by the given field.
- source_records_changed(changed_records=None)[source]¶
Notify the delegate that records have changed.
- load_tabular_data(filepath)[source]¶
Load tabular data from a CSV or Excel file and return a DataFrame.
FileViewer¶
- class mytk.fileviewer.FileRecord(uuid, puuid, name, size, modification_date, fullpath, is_system_file, is_directory, is_directory_content_loaded, depth_level)¶
Bases:
tuple- depth_level¶
Alias for field number 9
- fullpath¶
Alias for field number 5
- is_directory¶
Alias for field number 7
- is_directory_content_loaded¶
Alias for field number 8
- is_system_file¶
Alias for field number 6
- modification_date¶
Alias for field number 4
- name¶
Alias for field number 2
- puuid¶
Alias for field number 1
- size¶
Alias for field number 3
- uuid¶
Alias for field number 0
- class mytk.fileviewer.FileTreeData(root_dir, tableview, required_fields)[source]¶
Bases:
TabularDataA TabularData subclass that reads file system directory contents.
- is_directory(fullpath)[source]¶
Return whether the path is a directory, treating macOS bundles as files.
- recordid_with_fullpath(fullpath)[source]¶
Return the UUID of the record matching the given full path, or None.