本文整理汇总了Python中volumina.utility.decode_to_qstring函数的典型用法代码示例。如果您正苦于以下问题:Python decode_to_qstring函数的具体用法?Python decode_to_qstring怎么用?Python decode_to_qstring使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了decode_to_qstring函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handleMetadataChanged
def handleMetadataChanged():
if self.projectNameEdit.text() != self._projectMetadata.projectName:
self.projectNameEdit.setText( decode_to_qstring(self._projectMetadata.projectName) )
if self.labelerEdit.text() != self._projectMetadata.labeler:
self.labelerEdit.setText( decode_to_qstring(self._projectMetadata.labeler) )
if self.descriptionEdit.toPlainText() != self._projectMetadata.description:
self.descriptionEdit.setText( decode_to_qstring(self._projectMetadata.description) )
示例2: _chooseDirectory
def _chooseDirectory(self):
# Find the directory of the most recently opened image file
mostRecentStackDirectory = PreferencesManager().get( 'DataSelection', 'recent stack directory' )
if mostRecentStackDirectory is not None:
defaultDirectory = os.path.split(mostRecentStackDirectory)[0]
else:
defaultDirectory = os.path.expanduser('~')
options = QFileDialog.Options(QFileDialog.ShowDirsOnly)
if ilastik.config.cfg.getboolean("ilastik", "debug"):
options |= QFileDialog.DontUseNativeDialog
# Launch the "Open File" dialog
directory = QFileDialog.getExistingDirectory(
self, "Image Stack Directory", defaultDirectory, options=options )
if directory.isNull():
# User cancelled
return
directory = encode_from_qstring( directory )
PreferencesManager().set('DataSelection', 'recent stack directory', directory)
self.directoryEdit.setText( decode_to_qstring(directory) )
globstring = self._getGlobString(directory)
if globstring is not None:
filenames = [k.replace('\\', '/') for k in glob.glob(globstring)]
self._updateFileList( sorted(filenames) )
# As a convenience, also show the glob string in the pattern field
self.patternEdit.setText( decode_to_qstring(globstring) )
示例3: _initStorageCombo
def _initStorageCombo(self):
# If there's only one dataset, show the path in the combo
showpaths = False
relPath = None
if len( self._laneIndexes ) == 1:
op = self.tempOps.values()[0]
info = op.Dataset.value
cwd = op.WorkingDirectory.value
filePath = PathComponents(info.filePath).externalPath
absPath, relPath = getPathVariants(filePath, cwd)
# commented out:
# Show the paths even if the data is from a stack (they are grayed out, but potentially informative)
#showpaths = not info.fromstack
showpaths = True
if showpaths:
self.storageComboBox.addItem( "Copied to Project File", userData=StorageLocation.ProjectFile )
self.storageComboBox.addItem( decode_to_qstring("Absolute Link: " + absPath), userData=StorageLocation.AbsoluteLink )
if relPath is not None:
self.storageComboBox.addItem( decode_to_qstring("Relative Link: " + relPath), userData=StorageLocation.RelativeLink )
else:
self.storageComboBox.addItem( "Copied to Project File", userData=StorageLocation.ProjectFile )
self.storageComboBox.addItem( "Absolute Link", userData=StorageLocation.AbsoluteLink )
self.storageComboBox.addItem( "Relative Link", userData=StorageLocation.RelativeLink )
self.storageComboBox.setCurrentIndex(-1)
示例4: _updateFileList
def _updateFileList(self, files):
self.selectedFiles = files
self.fileListWidget.clear()
for f in self.selectedFiles:
self.fileListWidget.addItem(decode_to_qstring(f))
示例5: updateTableForSlot
def updateTableForSlot(self, slot):
"""
Update the table row that corresponds to the given slot of the top-level operator (could be either input slot)
"""
row = self.getSlotIndex( self.topLevelOperator.ExportPath, slot )
assert row != -1, "Unknown input slot!"
if not self.topLevelOperator.ExportPath[row].ready() or\
not self.topLevelOperator.RawDatasetInfo[row].ready():
return
try:
nickname = self.topLevelOperator.RawDatasetInfo[row].value.nickname
exportPath = self.topLevelOperator.ExportPath[row].value
except Slot.SlotNotReadyError:
# Sadly, it is possible to get here even though we checked for .ready() immediately beforehand.
# That's because the graph has a diamond-shaped DAG of connections, but the graph has no transaction mechanism
# (It's therefore possible for RawDatasetInfo[row] to be ready() even though it's upstream partner is NOT ready.
return
self.batchOutputTableWidget.setItem( row, Column.Dataset, QTableWidgetItem( decode_to_qstring(nickname, 'utf-8') ) )
self.batchOutputTableWidget.setItem( row, Column.ExportLocation, QTableWidgetItem( decode_to_qstring(exportPath) ) )
exportNowButton = QPushButton("Export")
exportNowButton.setToolTip("Generate individual batch output dataset.")
exportNowButton.clicked.connect( bind(self.exportResultsForSlot, self.topLevelOperator[row] ) )
self.batchOutputTableWidget.setCellWidget( row, Column.Action, exportNowButton )
# Select a row if there isn't one already selected.
selectedRanges = self.batchOutputTableWidget.selectedRanges()
if len(selectedRanges) == 0:
self.batchOutputTableWidget.selectRow(0)
示例6: _getDisplayRoleData
def _getDisplayRoleData(self, index):
laneIndex = index.row()
## Dataset info item
roleIndex = (index.column() - LaneColumn.NumColumns) // DatasetInfoColumn.NumColumns
datasetInfoIndex = (index.column() - LaneColumn.NumColumns) % DatasetInfoColumn.NumColumns
datasetSlot = self._op.DatasetGroup[laneIndex][roleIndex]
if not datasetSlot.ready():
return ""
UninitializedDisplayData = { DatasetInfoColumn.Name : "<please select>" }
datasetSlot = self._op.DatasetGroup[laneIndex][roleIndex]
if datasetSlot.ready():
datasetInfo = self._op.DatasetGroup[laneIndex][roleIndex].value
else:
return UninitializedDisplayData[ datasetInfoIndex ]
if datasetInfoIndex == DatasetInfoColumn.Name:
if datasetInfo.nickname is not None and datasetInfo.nickname != "":
return datasetInfo.nickname
return decode_to_qstring( PathComponents( datasetInfo.filePath ).filename )
if datasetInfoIndex == DatasetInfoColumn.Location:
LocationNames = { DatasetInfo.Location.FileSystem : "External File",
DatasetInfo.Location.ProjectInternal : "Project File" }
return LocationNames[ datasetInfo.location ]
assert False, "Unknown column"
示例7: _loadAnnotationFile
def _loadAnnotationFile(self, annotation_filepath):
"""
Load the annotation file using the path stored in our member variable.
"""
try:
# Configure operator
self.opSplitBodyCarving.AnnotationFilepath.setValue( annotation_filepath )
# Requesting annotations triggers parse.
self._annotations = self.opSplitBodyCarving.Annotations.value
self._ravelerLabels = self.opSplitBodyCarving.AnnotationBodyIds.value
# Update gui
self._reloadInfoWidgets()
self.annotationFilepathEdit.setText( decode_to_qstring(annotation_filepath) )
except OpParseAnnotations.AnnotationParsingException as ex :
if ex.original_exc is not None:
log_exception( logger, exc_info=( type(ex.original_exc), ex.original_exc, sys.exc_info[2]) )
else:
log_exception( logger )
QMessageBox.critical(self,
"Failed to parse",
ex.msg + "\n\nSee console output for details." )
self._annotations = None
self._ravelerLabels = None
self.annotationFilepathEdit.setText("")
except:
msg = "Wasn't able to parse your bookmark file. See console output for details."
QMessageBox.critical(self, "Failed to parse", msg )
log_exception( logger, msg )
self._annotations = None
self._ravelerLabels = None
self.annotationFilepathEdit.setText("")
示例8: _updatePathsFromSlot
def _updatePathsFromSlot(self):
if self._filepathSlot.ready():
file_path = self._filepathSlot.value
directory, filename_pattern = os.path.split( file_path )
filename_pattern = os.path.splitext(filename_pattern)[0]
# Auto-insert the {slice_index} field
if re.search("{slice_index(:.*)?}", filename_pattern) is None:
filename_pattern += '_{slice_index}'
self.directoryEdit.setText( decode_to_qstring(directory) )
self.filePatternEdit.setText( decode_to_qstring(filename_pattern + '.' + self._extension) )
# Re-configure the slot in case we changed the extension
file_path = os.path.join( directory, filename_pattern ) + '.' + self._extension
self._filepathSlot.setValue( file_path )
示例9: setNameAndBrush
def setNameAndBrush(self, sigma, color=Qt.black):
self.sigma = sigma
self.setText(
decode_to_qstring("σ=%.1fpx" % self.sigma, "utf-8")
) # This file is encoded as utf-8, so this string should be decoded as such.
total_window = 1 + 2 * int(self.sigma * self.window_size + 0.5)
self.setToolTip("sigma = {:.1f} pixels, window diameter = {:.1f}".format(self.sigma, total_window))
font = QFont()
font.setPointSize(10)
font.setBold(True)
self.setFont(font)
self.setForeground(color)
pixmap = QPixmap(self.pixmapSize)
pixmap.fill(Qt.transparent)
painter = QPainter()
painter.begin(pixmap)
painter.setRenderHint(QPainter.Antialiasing, True)
painter.setPen(color)
brush = QBrush(color)
painter.setBrush(brush)
painter.drawEllipse(
QRect(
self.pixmapSize.width() / 2 - self.brushSize / 2,
self.pixmapSize.height() / 2 - self.brushSize / 2,
self.brushSize,
self.brushSize,
)
)
painter.end()
self.setIcon(QIcon(pixmap))
self.setTextAlignment(Qt.AlignVCenter)
示例10: data
def data(self, index, role):
'''
Reimplement, see labelListModel or boxListModel for concrete example
:param index:
:param role:
'''
if role == Qt.EditRole and index.column() == self.ColumnID.Name:
name = self._elements[index.row()].name
return decode_to_qstring(name)
elif role == Qt.ToolTipRole and index.column() == self.ColumnID.Delete:
s = "Delete {}".format(self._elements[index.row()].name)
return decode_to_qstring(s)
elif role == Qt.ToolTipRole and index.column() == self.ColumnID.Name:
suffix = self._getToolTipSuffix(index.row())
s = "{}\nDouble click to rename {}".format(
self._elements[index.row()].name, suffix)
return decode_to_qstring(s)
elif role == Qt.DisplayRole and index.column() == self.ColumnID.Name:
name = self._elements[index.row()].name
return decode_to_qstring(name)
if role == Qt.DecorationRole and index.column() == self.ColumnID.Delete:
if index.row() in self.unremovable_rows: return
row = index.row()
pixmap = QPixmap(_NPIXELS, _NPIXELS)
pixmap.fill(Qt.transparent)
painter = QPainter()
painter.begin(pixmap)
painter.setRenderHint(QPainter.Antialiasing)
painter.setBrush(QColor("red"))
painter.drawEllipse(1, 1, _NPIXELS - 2, _NPIXELS - 2)
pen = QPen(QColor("black"))
pen.setWidth(2)
painter.setPen(pen)
x = _XSTART
y = _NPIXELS - x
painter.drawLine(x, x, y, y)
painter.drawLine(y, x, x, y)
painter.end()
icon = QIcon(pixmap)
return icon
示例11: updateFromSlot
def updateFromSlot(self):
if self._filepathSlot.ready():
file_path = self._filepathSlot.value
file_path = os.path.splitext(file_path)[0] + "." + self._extension
self.filepathEdit.setText( decode_to_qstring(file_path) )
# Re-configure the slot in case we changed the extension
self._filepathSlot.setValue( file_path )
示例12: name
def name( self, n ):
if isinstance(n, str):
n = decode_to_qstring(n, 'utf-8')
assert isinstance(n, QString)
pystr = encode_from_qstring(n, 'utf-8')
if self._name != n:
self._name = n
self.nameChanged.emit(pystr)
示例13: _updateNickname
def _updateNickname(self):
firstOp = self.tempOps.values()[0]
nickname = firstOp.Dataset.value.nickname
for op in self.tempOps.values():
info = op.Dataset.value
if nickname != info.nickname:
nickname = None
break
if nickname is None:
self.nicknameEdit.setText("<multiple>")
else:
self.nicknameEdit.setText( decode_to_qstring(nickname, 'utf-8') )
示例14: updateFromSlot
def updateFromSlot(self):
if self._urlSlot.ready():
# FIXME: Choose a default dvid url...
file_path = self._urlSlot.value
if not isUrl( file_path ):
file_path = ""
# Remove extension
file_path = os.path.splitext(file_path)[0]
self.urlLabel.setText( decode_to_qstring(file_path) )
# Re-configure the slot in case we removed the extension
self._urlSlot.setValue( file_path )
示例15: _browseForFilepath
def _browseForFilepath(self):
starting_dir = os.path.expanduser("~")
if self._filepathSlot.ready():
starting_dir = os.path.split(self._filepathSlot.value)[-1]
dlg = QFileDialog( self, "Export Location", starting_dir, self._file_filter )
dlg.setDefaultSuffix(self._extension)
dlg.setAcceptMode(QFileDialog.AcceptSave)
if not dlg.exec_():
return
exportPath = encode_from_qstring( dlg.selectedFiles()[0] )
self._filepathSlot.setValue( exportPath )
self.filepathEdit.setText( decode_to_qstring(exportPath) )