hscommon.gui.column¶
|
Cross-toolkit GUI-enabled column set for tables or outlines. |
|
Holds column attributes such as its name, width, visibility, etc. |
Expected interface for |
|
Expected interface for |
-
class
hscommon.gui.column.Columns(table, prefaccess=None, savename=None)¶ Cross-toolkit GUI-enabled column set for tables or outlines.
Manages a column set’s order, visibility and width. We also manage the persistence of these attributes so that we can restore them on the next run.
Subclasses
GUIObject. Expected view:ColumnsView.- Parameters
table – The table the columns belong to. It’s from there that we retrieve our column configuration and it must have a
COLUMNSattribute which is a list ofColumn. We also callsave_edits()on it from time to time. Technically, this argument can also be a tree, but there’s probably some sorting in the code to do to support this option cleanly.prefaccess – An object giving access to user preferences for the currently running app. We use this to make column attributes persistent. Must follow
PrefAccessInterface.savename (str) – The name under which column preferences will be saved. This name is in fact a prefix. Preferences are saved under more than one name, but they will all have that same prefix.
-
_view_updated()¶ (Virtual) Called after
viewhas been set.Doing nothing by default, this method is called after
viewhas been set (it isn’t called when it’s unset, however). Use this for initialization code that requires a view (which is often the whole of the initialization code).
-
column_by_index(index)¶ Return the
Columnhaving thelogical_indexindex.
-
column_display(colname)¶ Returns display name for column named
colname, or''if there’s none.
-
column_is_visible(colname)¶ Returns visibility for column named
colname, orTrueif there’s none.
-
column_width(colname)¶ Returns width for column named
colname, or0if there’s none.
-
columns_count()¶ Returns the number of columns in our set.
-
columns_to_right(colname)¶ Returns the list of all columns to the right of
colname.“right” meaning “having a higher
Column.ordered_index” in our left-to-right civilization.
Returns a list of items convenient for quick visibility menu generation.
Returns a list of
(display_name, is_marked)items for each optional column in the current view (is_markedmeans that it’s visible).You can use this to generate a menu to let the user toggle the visibility of an optional column. That is why we only show optional column, because the visibility of mandatory columns can’t be toggled.
-
move_column(colname, index)¶ Moves column
colnametoindex.The column will be placed just in front of the column currently having that index, or to the end of the list if there’s none.
-
reset_to_defaults()¶ Reset all columns’ width and visibility to their default values.
-
resize_column(colname, newwidth)¶ Set column
colname’s width tonewwidth.
-
restore_columns()¶ Restore’s column persistent attributes from the last
save_columns().
-
save_columns()¶ Save column attributes in persistent storage for restoration in
restore_columns().
-
set_column_order(colnames)¶ Change the columns order so it matches the order in
colnames.- Parameters
colnames – A list of column names in the desired order.
-
set_column_visible(colname, visible)¶ Set the visibility of column
colname.
-
set_default_width(colname, width)¶ Set the default width or column
colname.
Toggles the visibility of an optional column.
You know, that optional column menu you’ve generated in
menu_items()? Well,indexis the index of them menu item in that menu that the user has clicked on to toggle it.Returns whether the column in question ends up being visible or not.
-
property
colnames¶ List of column names in visible order.
-
class
hscommon.gui.column.Column(name, display='', visible=True, optional=False)¶ Holds column attributes such as its name, width, visibility, etc.
These attributes are then used to correctly configure the column on the “view” side.
-
default_visible= None¶ Whether the column is visible by default. It will be used if column restoration doesn’t contain any “remembered” widths.
-
default_width= None¶ Default width of the column. This value usually depends on the platform and is set on columns initialisation. It will be used if column restoration doesn’t contain any “remembered” widths.
-
display= None¶ Display name (title) of the column.
-
logical_index= None¶ Immutable index of the column. Doesn’t change even when columns are re-ordered. Used in
Columns.column_by_index().
-
name= None¶ “programmatical” (not for display) name. Used as a reference in a couple of place, such as
Columns.column_by_name().
-
ordered_index= None¶ Index of the column in the ordered set of columns.
-
visible= None¶ Whether the column is visible.
-
width= None¶ Width of the column.
-
-
class
hscommon.gui.column.ColumnsView¶ Expected interface for
Columns’s view.Not actually used in the code. For documentation purposes only.
Our view, the columns controller of a table or outline, is expected to properly respond to callbacks.
-
restore_columns()¶ Update all columns according to the model.
When this is called, our view has to update the columns title, order and visibility of all columns.
-
set_column_visible(colname, visible)¶ Update visibility of column
colname.Called when the user toggles the visibility of a column, we must update the column
colname’s visibility status tovisible.
-
-
class
hscommon.gui.column.PrefAccessInterface¶ Expected interface for
Columns’s prefaccess.Not actually used in the code. For documentation purposes only.
-
get_default(key, fallback_value)¶ Retrieve the value for
keyin the currently running app’s preference store.If the key doesn’t exist, return
fallback_value.
-
set_default(key, value)¶ Set the value
valueforkeyin the currently running app’s preference store.
-