Making keyboard shortcuts to open modules

Try this :

#Makes selected module to popup as second module
def openSegmentEditor():
  mainWindow = slicer.util.mainWindow()
  mainWindow.moduleSelector().selectModule('SegmentEditor')

  
  
#setup the short cut
shortcut1 = qt.QShortcut(slicer.util.mainWindow())
shortcut1.setKey(qt.QKeySequence('Ctrl+n'))
shortcut1.connect('activated()', lambda: openSegmentEditor())

Use single quotes only : ‘activated()’ -> 'activated()'

1 Like