Skip to content

Commit

Permalink
Use a new module and class for choosing directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Davis authored and Luke Davis committed Sep 29, 2024
1 parent dcff141 commit bd06184
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
4 changes: 2 additions & 2 deletions addon/globalPlugins/speechLogger/configUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
import config
import ui
import globalVars
import gui
from gui.settingsDialogs import PANEL_DESCRIPTION_WIDTH
from logHandler import log

from . import extensionPoint
from .slPathSelectionHelper import SLPathSelectionHelper

try:
addonHandler.initTranslation()
Expand Down Expand Up @@ -155,7 +155,7 @@ def makeSettings(self, settingsSizer) -> None:
browseButtonLabel: str = _("Browse...")
# Translators: The title of the dialog presented when browsing for the log directory.
dirChooserTitle: str = _("Select log directory")
dirChooserHelper = gui.guiHelper.PathSelectionHelper(fileGroupBox, browseButtonLabel, dirChooserTitle)
dirChooserHelper = SLPathSelectionHelper(fileGroupBox, browseButtonLabel, dirChooserTitle)
directoryEntryControl = fileGroupHelper.addItem(dirChooserHelper)
self.logDirectoryEdit = directoryEntryControl.pathControl
self.logDirectoryEdit.SetValue(getConf("folder"))
Expand Down
29 changes: 29 additions & 0 deletions addon/globalPlugins/speechLogger/slPathSelectionHelper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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)
2 changes: 1 addition & 1 deletion buildVars.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.500",
"addon_version": "24.2.506",
# Author(s)
"addon_author": "Luke Davis <XLTechie@newanswertech.com>, James Scholes",
# URL for the add-on documentation support
Expand Down

0 comments on commit bd06184

Please sign in to comment.