From 1eccba10ca46a78748252835f7f60b0bcb267764 Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Thu, 9 Dec 2021 22:04:47 -0600 Subject: [PATCH] Path: Translation Solution POC --- src/Mod/Path/PathScripts/PathOpGui.py | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/Mod/Path/PathScripts/PathOpGui.py b/src/Mod/Path/PathScripts/PathOpGui.py index dd080c48c4..2f35d6338e 100644 --- a/src/Mod/Path/PathScripts/PathOpGui.py +++ b/src/Mod/Path/PathScripts/PathOpGui.py @@ -363,6 +363,36 @@ class TaskPanelPage(object): combo.setCurrentIndex(index) combo.blockSignals(False) + def selectInComboBoxNew(self, name, combo): + '''selectInComboBox(name, combo) ... + helper function to select a specific value in a combo box.''' + combo.blockSignals(True) + cnt = combo.count() + index = combo.currentIndex() # Save initial index + while cnt > 0: + cnt -= 1 + combo.setCurrentIndex(cnt) + if name == combo.currentData(): + combo.blockSignals(False) + return + combo.setCurrentIndex(index) + combo.blockSignals(False) + + def populateCombobox(self, form, enumTups, comboBoxesPropertyMap): + """fillComboboxes(form, comboBoxesPropertyMap) ... populate comboboxes with translated enumerations + ** comboBoxesPropertyMap will be unnecessary if UI files use strict combobox naming protocol. + Args: + form = UI form + enumTups = list of (translated_text, data_string) tuples + comboBoxesPropertyMap = list of (translated_text, data_string) tuples + """ + # Load appropriate enumerations in each combobox + for cb, prop in comboBoxesPropertyMap: + box = getattr(form, cb) # Get the combobox + box.clear() # clear the combobox + for text, data in enumTups[prop]: # load enumerations + box.addItem(text, data) + def resetToolController(self, job, tc): if self.obj is not None: self.obj.ToolController = tc