Skip to content

Commit 837f8d3

Browse files
committed
ENH: Update ScriptedLoadableModuleWidget to support UI editing from installation
git-svn-id: http://svn.slicer.org/Slicer4/trunk@27710 3bd1e089-480b-0410-8dfb-8563597acbee
1 parent 4c0d77f commit 837f8d3

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

Base/Python/slicer/ScriptedLoadableModule.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,14 @@ def createHLayout(elements):
150150
self.editSourceButton.connect('clicked()', self.onEditSource)
151151

152152
self.editModuleUiButton = None
153-
# Current limitation: Qt Designer is only availabe in the build tree,
154-
# not bundled with the installed application. Therefore, the "Edit UI"
155-
# button may only shown if the application is not installed.
156-
if not slicer.app.isInstalled:
157-
moduleUiFileName = self.resourcePath('UI/%s.ui' % self.moduleName)
158-
print(moduleUiFileName)
159-
import os.path
160-
if os.path.isfile(moduleUiFileName):
161-
# Module UI file exists
162-
self.editModuleUiButton = qt.QPushButton("Edit UI")
163-
self.editModuleUiButton.toolTip = "Edit the module's .ui file."
164-
self.editModuleUiButton.connect('clicked()', lambda filename=moduleUiFileName: slicer.util.startQtDesigner(moduleUiFileName))
153+
moduleUiFileName = self.resourcePath('UI/%s.ui' % self.moduleName)
154+
print(moduleUiFileName)
155+
import os.path
156+
if os.path.isfile(moduleUiFileName):
157+
# Module UI file exists
158+
self.editModuleUiButton = qt.QPushButton("Edit UI")
159+
self.editModuleUiButton.toolTip = "Edit the module's .ui file."
160+
self.editModuleUiButton.connect('clicked()', lambda filename=moduleUiFileName: slicer.util.startQtDesigner(moduleUiFileName))
165161

166162
# restart Slicer button
167163
# (use this during development, but remove it when delivering

Base/Python/slicer/util.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,14 @@ def loadUI(path):
285285

286286
def startQtDesigner(args = None):
287287
""" Start Qt Designer application to allow editing UI files.
288-
This only works if the launcher has properly configured with --designer option,
289-
which is currently only available in the build tree, not in installed applications.
290288
"""
291-
289+
import os
292290
import slicer
293291
import subprocess
294-
executableFilePath = slicer.app.launcherExecutableFilePath
295-
cmdLineArguments = ['--designer']
292+
executableFilePath = os.path.join(slicer.app.slicerHome, "bin", "SlicerDesigner")
293+
if slicer.app.os == 'win':
294+
executableFilePath += ".exe"
295+
cmdLineArguments = []
296296
if args is not None:
297297
if isinstance(args, basestring):
298298
cmdLineArguments.append(args)

0 commit comments

Comments
 (0)