11# objectViewer add-on for NVDA
22# This file is covered by the GNU General Public License.
33# See the file COPYING.txt for more details.
4- # Copyright (C) 2024 hwf1324 <1398969445@qq.com>
4+ # Copyright (C) 2024-2025 hwf1324 <1398969445@qq.com>
55
66import api
77import config
2727
2828
2929class ObjectViewerTool :
30-
3130 # Note: This is the Borg design pattern which ensures that all
3231 # instances of this class are actually using the same set of
3332 # instance data. See
@@ -47,6 +46,7 @@ def init(self):
4746 self ._frame = None
4847
4948 import pythonConsole
49+
5050 if not pythonConsole .consoleUI :
5151 pythonConsole .initialize ()
5252 self ._namespace = pythonConsole .consoleUI .console .namespace
@@ -58,10 +58,7 @@ def show(self, selectObj: NVDAObject = None, refreshTree: bool = False):
5858 self .init ()
5959
6060 if not self ._frame :
61- self ._frame = ObjectViewerFrame (
62- gui .mainFrame ,
63- namespace = self ._namespace
64- )
61+ self ._frame = ObjectViewerFrame (gui .mainFrame , namespace = self ._namespace )
6562
6663 import pythonConsole
6764
@@ -85,31 +82,31 @@ def __init__(self):
8582 @script (
8683 # Translators: Description of the script to activate the Objects Viewer.
8784 description = _ ("Activate the Object Viewer" ),
88- category = SCRCAT_OBJECTS_VIEWER
85+ category = SCRCAT_OBJECTS_VIEWER ,
8986 )
9087 def script_activateObjectViewer (self , gesture ):
9188 ObjectViewerTool ().show ()
9289
9390 @script (
9491 # Translators: Description of the script to activate the Objects Viewer.
9592 description = _ ("Activate the Object Viewer from focus object" ),
96- category = SCRCAT_OBJECTS_VIEWER
93+ category = SCRCAT_OBJECTS_VIEWER ,
9794 )
9895 def script_activateObjectViewerFromFocus (self , gesture ):
9996 ObjectViewerTool ().show (selectObj = api .getFocusObject ())
10097
10198 @script (
10299 # Translators: Description of the script to activate the Objects Viewer.
103100 description = _ ("Activate the Object Viewer from mouse object" ),
104- category = SCRCAT_OBJECTS_VIEWER
101+ category = SCRCAT_OBJECTS_VIEWER ,
105102 )
106103 def script_activateObjectViewerFromMouse (self , gesture ):
107104 ObjectViewerTool ().show (selectObj = api .getMouseObject ())
108105
109106 @script (
110107 # Translators: Description of the script to activate the Objects Viewer.
111108 description = _ ("Activate the Object Viewer from navigator object" ),
112- category = SCRCAT_OBJECTS_VIEWER
109+ category = SCRCAT_OBJECTS_VIEWER ,
113110 )
114111 def script_activateObjectViewerFromNavigator (self , gesture ):
115112 ObjectViewerTool ().show (selectObj = api .getNavigatorObject ())
0 commit comments