From b5bc1f785f772774b6b463726ca3e9f61d78e522 Mon Sep 17 00:00:00 2001 From: Luke Davis Date: Sun, 29 Sep 2024 22:58:38 -0400 Subject: [PATCH] Trying to move new class, and initialize without super. --- addon/globalPlugins/speechLogger/configUI.py | 29 ++++++++++++++++++- .../speechLogger/slPathSelectionHelper.py | 29 ------------------- buildVars.py | 2 +- 3 files changed, 29 insertions(+), 31 deletions(-) delete mode 100644 addon/globalPlugins/speechLogger/slPathSelectionHelper.py diff --git a/addon/globalPlugins/speechLogger/configUI.py b/addon/globalPlugins/speechLogger/configUI.py index 7666f2b..0f19e9f 100644 --- a/addon/globalPlugins/speechLogger/configUI.py +++ b/addon/globalPlugins/speechLogger/configUI.py @@ -11,6 +11,7 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import wx +from wx.lib.expando import ExpandoTextCtrl from typing import Any import addonHandler @@ -19,10 +20,11 @@ import globalVars import gui from gui.settingsDialogs import PANEL_DESCRIPTION_WIDTH +from gui.dpiScalingHelper import scaleSize +from gui import guiHelper from logHandler import log from . import extensionPoint -from .slPathSelectionHelper import SLPathSelectionHelper try: addonHandler.initTranslation() @@ -291,3 +293,28 @@ def onSeparatorChoiceChange(self, evt): else: self.customSeparatorControl.Enable(False) + +class SLPathSelectionHelper(guiHelper.PathSelectionHelper): + """ + Abstracts away details for creating a path selection helper. The path selection helper is a textCtrl with a + button in horizontal layout. The Button launches a directory explorer. To get the path selected by the user, use the + `pathControl` property which exposes a wx.TextCtrl. + """ + + def __init__(self, parent: wx.Dialog, buttonText: str, browseForDirectoryTitle: str) -> None: + """ + :param parent: An instance of the parent wx window. EG wx.Dialog + :param buttonText: The text for the button to launch a directory dialog (wx.DirDialog). This is typically 'Browse' + :param browseForDirectoryTitle: The text for the title of the directory dialog (wx.DirDialog) + """ + object.__init__(self) + self._textCtrl = ExpandoTextCtrl( + parent, + size=(scaleSize(250), -1), + style=wx.TE_READONLY, + ) + self._browseButton = wx.Button(parent, label=buttonText) + self._browseForDirectoryTitle = browseForDirectoryTitle + self._browseButton.Bind(wx.EVT_BUTTON, self.onBrowseForDirectory) + self._sizer = associateElements(self._textCtrl, self._browseButton) + diff --git a/addon/globalPlugins/speechLogger/slPathSelectionHelper.py b/addon/globalPlugins/speechLogger/slPathSelectionHelper.py deleted file mode 100644 index 0e6fe48..0000000 --- a/addon/globalPlugins/speechLogger/slPathSelectionHelper.py +++ /dev/null @@ -1,29 +0,0 @@ -import wx -from gui.dpiScalingHelper import scaleSize -from wx.lib.expando import ExpandoTextCtrl -from gui import guiHelper - - -class SLPathSelectionHelper(guiHelper.PathSelectionHelper): - """ - Abstracts away details for creating a path selection helper. The path selection helper is a textCtrl with a - button in horizontal layout. The Button launches a directory explorer. To get the path selected by the user, use the - `pathControl` property which exposes a wx.TextCtrl. - """ - - def __init__(self, parent: wx.Dialog, buttonText: str, browseForDirectoryTitle: str) -> None: - """ - :param parent: An instance of the parent wx window. EG wx.Dialog - :param buttonText: The text for the button to launch a directory dialog (wx.DirDialog). This is typically 'Browse' - :param browseForDirectoryTitle: The text for the title of the directory dialog (wx.DirDialog) - """ - super().__init__(self) - self._textCtrl = ExpandoTextCtrl( - parent, - size=(scaleSize(250), -1), - style=wx.TE_READONLY, - ) - self._browseButton = wx.Button(parent, label=buttonText) - self._browseForDirectoryTitle = browseForDirectoryTitle - self._browseButton.Bind(wx.EVT_BUTTON, self.onBrowseForDirectory) - self._sizer = associateElements(self._textCtrl, self._browseButton) diff --git a/buildVars.py b/buildVars.py index 3203265..185c36c 100644 --- a/buildVars.py +++ b/buildVars.py @@ -25,7 +25,7 @@ def _(arg): # Translators: Long description to be shown for this add-on on add-on information from add-ons manager "addon_description": _("""Logs speech utterances to a file, after the user presses an initiating key. Can also log NVDA remote session speech from the NVDA Remote add-on, to the same or another file. Optionally includes speech from say-all."""), # version - "addon_version": "24.2.507", + "addon_version": "24.2.508", # Author(s) "addon_author": "Luke Davis , James Scholes", # URL for the add-on documentation support