@@ -295,7 +295,8 @@ def toggle_outlineexplorer(self, value):
295
295
height = self .SPLITTER_WIDTH
296
296
)
297
297
self .splitter .setStyleSheet (self ._splitter_css .toString ())
298
- self .splitter .handle (1 ).setEnabled (True )
298
+ if self .splitter .handle (1 ) is not None :
299
+ self .splitter .handle (1 ).setEnabled (True )
299
300
else :
300
301
self ._sizes = self .splitter .sizes ()
301
302
self .splitter .setChildrenCollapsible (True )
@@ -309,7 +310,8 @@ def toggle_outlineexplorer(self, value):
309
310
height = "0px"
310
311
)
311
312
self .splitter .setStyleSheet (self ._splitter_css .toString ())
312
- self .splitter .handle (1 ).setEnabled (False )
313
+ if self .splitter .handle (1 ) is not None :
314
+ self .splitter .handle (1 ).setEnabled (False )
313
315
314
316
self .splitter .setChildrenCollapsible (False )
315
317
@@ -364,7 +366,13 @@ def __init__(self, plugin, menu_actions, outline_plugin, parent=None):
364
366
]
365
367
366
368
for toolbar_id in toolbar_list :
367
- toolbar = self .get_toolbar (toolbar_id , plugin = Plugins .Toolbar )
369
+ # This is necessary to run tests for this widget without Spyder's
370
+ # main window
371
+ try :
372
+ toolbar = self .get_toolbar (toolbar_id , plugin = Plugins .Toolbar )
373
+ except KeyError :
374
+ continue
375
+
368
376
new_toolbar = ApplicationToolbar (self , toolbar_id , toolbar ._title )
369
377
for action in toolbar .actions ():
370
378
new_toolbar .add_item (
@@ -397,9 +405,14 @@ def __init__(self, plugin, menu_actions, outline_plugin, parent=None):
397
405
view_menu = self ._create_view_menu ()
398
406
self .menuBar ().addMenu (view_menu )
399
407
else :
400
- self .menuBar ().addMenu (
401
- self .get_menu (menu_id , plugin = Plugins .MainMenu )
402
- )
408
+ # This is necessary to run tests for this widget without
409
+ # Spyder's main window
410
+ try :
411
+ self .menuBar ().addMenu (
412
+ self .get_menu (menu_id , plugin = Plugins .MainMenu )
413
+ )
414
+ except KeyError :
415
+ continue
403
416
404
417
# ---- Qt methods
405
418
# -------------------------------------------------------------------------
0 commit comments