rhyton.ui¶
Module for interacting with the user. Provides ready-made functions that can be used by buttons in any extension.
- class ColorSchemeEditor[source]¶
Bases:
object- __init__()[source]¶
Inits a new ColorSchemeEditor Instance. Asks the user to select a color scheme and opens a dialog to edit the colors.
- class Export[source]¶
Bases:
object- __init__()[source]¶
Inits a new export Instance. Asks the user to select the export format, gets memorized checkbox values for available keys. Presents those to the user to select the keys for export. Stores checkbox states and exports keys to selected output format.
- static getCheckboxDefaults(flag, keys=[])[source]¶
Loads export checkbox defaults from the document config storage for given keys. If no default is available in the document config storage, <True> will be used.
- Parameters
flag (str) – The identifier for the default values in the document config storage.
keys (list(str)) – A list of keys to get default values for.
- Returns
A list of tuples indicating the defaults for given values.
- Return type
tuple
- classmethod getExportKeys(flag, guids)[source]¶
Presents a checkbox to the user to pick the user text keys for export. The checkbox states are stored in the document config storage and are used a the default values for the next time the dialog is shown.
- Parameters
flag (str) – The identifier for the default values in the document config storage.
guids (str) – A list of Rhino object ids.
- Returns
A list of user text keys.
- Return type
list(str)
- static setCheckboxDefaults(flag, newDefaults)[source]¶
Updates the document config storage with new export checkbox defaults for the current extension.
- Parameters
flag (str) – The identifier for the default values in the document config storage.
defaults (tuple) – A list of tuples indicating the default per value.
- class Powerbi[source]¶
Bases:
objectClass for opening and updating PowerBI.
- CUSTOM_TEMPLATE = 'Load Custom Template'¶
- POWERBI_DATAFILE = 'C:/HdM-DT/RhinoToolbarExtensions/powerbi.json'¶
- POWERBI_TEMPLATE = '.template'¶
- POWERBI_TEMPLATES_DIR = 'C:/HdM-DT/RhinoToolbarExtensions/powerbi-templates'¶
- POWERBI_TEMPLATES_EXTENSION = '.pbit'¶
- TIMESTAMP = 'timestamp'¶
- VIZ_KEY = 'visualization_parameter'¶
- static absoluteFilePaths(directory)[source]¶
This method is used to get all absolute file paths in a directory.
- Parameters
directory (str) – The directory to search.
- Yields
list(str) – The absolute file paths.
- static fixedKeys()[source]¶
Generates fixed keys when needed. This cannot be done as a class variable because the extension name might change.
- Yields
list(str) – The fixed keys.
- classmethod show()[source]¶
This method is used to start PowerBI.
It checks if PowerBI is already running and if not, it opens it. The user can select a pre-defined template or load a custom template. When a pre-defined template is selected, certain parameters are fixed to ensure that the query and visuals in powerbi do not break. The user is asked to select a parameter to visualize which is then renamend to meet the PowerBI template requirements.
The data is then written to a json file and PowerBI is opened.
- class ProgressBar(upper, label='Calculating...', lower=1)[source]¶
Bases:
objectThis class is used to create and update a progress bar.
- __enter__()[source]¶
This method is used to show the progress bar.
- Returns
The progress bar object.
- Return type
object
- __exit__(exc_type, exc_val, traceback)[source]¶
This method is used to hide the progress bar.
- Parameters
exc_type (_type_) – _description_
exc_val (_type_) – _description_
traceback (_type_) – _description_
- __init__(upper, label='Calculating...', lower=1)[source]¶
The constructor for the ProgressBar class.
- Parameters
upper (int) – The upper limit of the progress bar.
label (str, optional) – The text to display in the progress bar. Defaults to “Calculating…”.
lower (int, optional) – the lower limit of the progress bar. Defaults to 1.
- class SelectionWindow[source]¶
Bases:
objectWrapper class for Rhino user interfaces.
- static dictBox(options, message=None)[source]¶
Show a dictionary-style list box to the user.
- Parameters
options (dict) – The key, value pairs.
message (str, optional) – The message to the user. Defaults to None.
- static show(options, message=None)[source]¶
Shows a list box to the user that allows to select from a list of options.
- Parameters
options (mixed) – A list of strings or dict (shows keys to user, returns value).
message (str, optional) – The message to the user. Defaults to None.
- Returns
The value of the selected key from the input dictionary or the selected item from the input list.
- Return type
mixed
- static showBoxes(options, message=None)[source]¶
Shows a checkbox list to the user that allows to select from multiple items.
Example input/output:
[("option1", True), ("option2", False)]
The returns are formatted as shown above.
- Parameters
options (list(tuple)) – A list of tuples with pre-defined checkbox states
message (str, optional) – The message to the user. Defaults to None.
- Returns
A list of tuples indicating the name and state of each checkbox.
- Return type
list(tuple)
- class Settings(extensionName)[source]¶
Bases:
rhyton.main.RhytonClass for handling extension settings.
- COLOR = 'color'¶
- COLOR_SCHEMES = '.colorSchemes'¶
- COLOR_SOURCE = 'colorSource'¶
- CSV = 'CSV'¶
- DELIMITER = '_'¶
- EMPTY = '<empty>'¶
- EXPORT_CHECKBOXES = 'exportCheckboxes'¶
- EXTENSION_NAME = 'rhyton'¶
- FONT = 'Arial'¶
- GROUP = '.group'¶
- GUID = 'guid'¶
- HDM_DT_DIR = 'C:/HdM-DT'¶
- HEX_WHITE = '#FFFFFF'¶
- JSON = 'JSON'¶
- KEY_PREFIX_NAME = 'key_prefix'¶
- LAYER_HIERARCHY = 'layer_hierarchy'¶
- NAME = 'name'¶
- NOT_AVAILABLE = 'n/a'¶
- ORIGINAL_COLORS = '.originalColors'¶
- POWERBI = '.powerbi'¶
- RHYTON_CONFIG = 'RHYTON_CONFIG'¶
- ROUNDING_DECIMALS = 2¶
- ROUNDING_DECIMALS_NAME = 'rounding_decimals'¶
- SETTINGS = '.settings'¶
- STANDARD_COLOR_1 = (200, 200, 255)¶
- STANDARD_COLOR_2 = (50, 50, 255)¶
- TEXTDOTS = '.textDots'¶
- UNIT_SUFFIX_NAME = 'unit_suffix'¶
- WHITESPACE = ' '¶
- property extensionColorSchemes¶
The global color scheme identifier prefixied with the current extension.
- Returns
The color scheme identifier
- Return type
string
- property extensionGroup¶
The global group identifier prefixied with the current extension.
- Returns
The group identifier
- Return type
string
- property extensionName¶
The current extension name.
- Returns
The name of the currently active extension
- Return type
string
- property extensionOriginalColors¶
The global original colors identifier prefixied with the current extension.
- Returns
The original colors identifier
- Return type
string
- property extensionPowerbi¶
The global powerbi identifier prefixied with the current extension.
- Returns
The powerbi identifier
- Return type
string
- property extensionSettings¶
The global settings identifier prefixied with the current extension.
- Returns
The settings identifier
- Return type
string
- property extensionTextdots¶
The global text dot identifier prefixied with the current extension.
- Returns
The text dot identifier
- Return type
string
- generateSettings()¶
Generates a settings configuration.
- Returns
The resulting configuration.
- Return type
dict
- getSettings()¶
Gets a settings configuration from the document text.
- Returns
The configuration.
- Return type
dict
- saveSettings(settings)¶
Saves a configuration to the document text.
- Parameters
settings (dict) – The configuration to save.
- property unitSuffix¶
The unit suffix.
- Returns
The unit suffix.
- Return type
string
- class Visualize[source]¶
Bases:
objectClass for visualizing user text on Rhino objects.
- classmethod byGroup()[source]¶
Visualizes a set of Rhino objects and their user text: The user input ‘Parameter to Group By’ is used for coloring and grouping objects, as well as for building sub-totals of the user-selected ‘Parameter to Summarize’. Places text dots with the value for each group.
- classmethod byValue()[source]¶
Visualizes the value of selected parameter for each object individually. Applies a user-defined color gradient to the values.