generated from nvdaaddons/AddonTemplate
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a new module and class for choosing directory
- Loading branch information
Luke Davis
authored and
Luke Davis
committed
Sep 29, 2024
1 parent
dcff141
commit bd06184
Showing
3 changed files
with
32 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters