(self)
| 266 | """ |
| 267 | |
| 268 | def setup(self): |
| 269 | ScriptedLoadableModuleWidget.setup(self) |
| 270 | |
| 271 | # This module is often used in developer mode, therefore |
| 272 | # collapse reload & test section by default. |
| 273 | if hasattr(self, "reloadCollapsibleButton"): |
| 274 | self.reloadCollapsibleButton.collapsed = True |
| 275 | |
| 276 | self.logic = SampleDataLogic(self.logMessage) |
| 277 | |
| 278 | self.categoryLayout = qt.QVBoxLayout() |
| 279 | self.categoryLayout.setContentsMargins(0, 0, 0, 0) |
| 280 | self.layout.addLayout(self.categoryLayout) |
| 281 | |
| 282 | SampleDataWidget.setCategoriesFromSampleDataSources(self.categoryLayout, slicer.modules.sampleDataSources, self.logic) |
| 283 | if self.developerMode is False: |
| 284 | self.setCategoryVisible(self.logic.developmentCategoryName, False) |
| 285 | |
| 286 | customFrame = ctk.ctkCollapsibleGroupBox() |
| 287 | self.categoryLayout.addWidget(customFrame) |
| 288 | customFrame.title = _("Load data from URL") |
| 289 | customFrameLayout = qt.QVBoxLayout() |
| 290 | customFrame.setLayout(customFrameLayout) |
| 291 | self.customSampleLabel = qt.QLabel(_("Download URLs:")) |
| 292 | customFrameLayout.addWidget(self.customSampleLabel) |
| 293 | self.customSampleUrlEdit = qt.QTextEdit() |
| 294 | self.customSampleUrlEdit.toolTip = _("Enter one or more URLs (one per line) to download and load the corresponding data sets. " |
| 295 | "Press Ctrl+Enter or click 'Load' button to start loading.") |
| 296 | |
| 297 | # Install event filter to catch Ctrl+Enter keypress to start loading |
| 298 | self.customSampleUrlEditFinishedEventFilter = TextEditFinishEventFilter() |
| 299 | self.customSampleUrlEditFinishedEventFilter.textEditFinishedCallback = self.onCustomDataDownload |
| 300 | self.customSampleUrlEdit.installEventFilter(self.customSampleUrlEditFinishedEventFilter) |
| 301 | |
| 302 | customFrameLayout.addWidget(self.customSampleUrlEdit) |
| 303 | self.customDownloadButton = qt.QPushButton(_("Load")) |
| 304 | self.customDownloadButton.toolTip = _("Download the dataset from the given URL and import it into the scene") |
| 305 | self.customDownloadButton.default = True |
| 306 | customFrameLayout.addWidget(self.customDownloadButton) |
| 307 | self.showCustomDataFolderButton = qt.QPushButton(_("Show folder")) |
| 308 | self.showCustomDataFolderButton.toolTip = _("Show folder where custom data sets are downloaded ({path}).").format(path=slicer.app.cachePath) |
| 309 | customFrameLayout.addWidget(self.showCustomDataFolderButton) |
| 310 | customFrame.collapsed = True |
| 311 | self.customDownloadButton.connect("clicked()", self.onCustomDataDownload) |
| 312 | self.showCustomDataFolderButton.connect("clicked()", self.onShowCustomDataFolder) |
| 313 | |
| 314 | self.log = qt.QTextEdit() |
| 315 | self.log.readOnly = True |
| 316 | self.layout.addWidget(self.log) |
| 317 | |
| 318 | # Add spacer to layout |
| 319 | self.layout.addStretch(1) |
| 320 | |
| 321 | def cleanup(self): |
| 322 | SampleDataWidget.setCategoriesFromSampleDataSources(self.categoryLayout, {}, self.logic) |
nothing calls this directly
no test coverage detected