本文整理汇总了Python中pyqtgraph.python2_3.asUnicode函数的典型用法代码示例。如果您正苦于以下问题:Python asUnicode函数的具体用法?Python asUnicode怎么用?Python asUnicode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了asUnicode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
def update(self):
''' uodate the model of the MENU (header)'''
N_index = len(self.df.index)
for name in self.df.columns:
# append a table with three columns (Name, Data-Type and N_NaNs). Each row represents
# a data-column in the input dataframe object
item_name = QtGui.QStandardItem(asUnicode('{0}'.format(name.encode('UTF-8'))))
item_name.setCheckable(True)
item_name.setEditable(False)
item_name.setCheckState(Qt.Checked)
dt = self.df[name].dtype if isinstance(self.df, pd.DataFrame) else self.df.dtype
item_type = QtGui.QStandardItem(asUnicode('{0}'.format(dt)))
item_type.setEditable(False)
if dt == type(object):
# if the data-type of the column is not numeric or datetime, then it's propabply has not been
# loaded successfully. Therefore, explicitly change the font color to red, to inform the user.
item_type.setForeground(RED_FONT)
n_nans = N_index - (self.df[name].count() if isinstance(self.df, pd.DataFrame) else self.df.count())
item_nans = QtGui.QStandardItem(asUnicode('{0}'.format(n_nans)))
item_nans.setEditable(False)
if n_nans > 0:
item_nans.setForeground(RED_FONT)
self.appendRow([item_name, item_type, item_nans])
self.setHorizontalHeaderLabels(['Name', 'Data-type', 'Number of NaNs'])
self.endResetModel()
示例2: updateDisplayLabel
def updateDisplayLabel(self, value=None):
"""Update the display label to reflect the value of the parameter."""
if value is None:
value = self.param.value()
opts = self.param.opts
if isinstance(self.widget, QtGui.QAbstractSpinBox):
text = asUnicode(self.widget.lineEdit().text())
elif isinstance(self.widget, QtGui.QComboBox):
text = self.widget.currentText()
else:
text = asUnicode(value)
self.displayLabel.setText(text)
示例3: on_selectFile_valueChanged
def on_selectFile_valueChanged(self, value):
button = self.param('Select File').items.items()[0][0].button
fname = asUnicode(self.param('Select File').value()).encode('UTF-8')
self._parent.sigUIStateChanged.emit(self)
if fname is not None and os.path.isfile(fname):
#print fname, type(fname)
#print u'File is selected: {0}'.format(fname)
#print type(asUnicode('File is selected: {0}'.format(fname)))
button.setToolTip(asUnicode('File is selected: {0}'.format(fname)))
button.setStatusTip(asUnicode('File is selected: {0}'.format(fname)))
else:
button.setToolTip(asUnicode('Select File'))
button.setStatusTip(asUnicode('Select File'))
示例4: fileSaveFinished
def fileSaveFinished(self, fileName):
fileName = asUnicode(fileName)
global LastExportDirectory
LastExportDirectory = os.path.split(fileName)[0]
## If file name does not match selected extension, append it now
ext = os.path.splitext(fileName)[1].lower().lstrip('.')
selectedExt = re.search(r'\*\.(\w+)\b', asUnicode(self.fileDialog.selectedNameFilter()))
if selectedExt is not None:
selectedExt = selectedExt.groups()[0].lower()
if ext != selectedExt:
fileName = fileName + '.' + selectedExt.lstrip('.')
self.export(fileName=fileName, **self.fileDialog.opts)
示例5: labelString
def labelString(self):
if self.labelUnits == '':
if self.scale == 1.0:
units = ''
else:
units = asUnicode('(x%g)') % (1.0/self.scale)
else:
#print repr(self.labelUnitPrefix), repr(self.labelUnits)
units = asUnicode('(%s%s)') % (self.labelUnitPrefix, self.labelUnits)
s = asUnicode('%s %s') % (self.labelText, units)
style = ';'.join(['%s: %s' % (k, self.labelStyle[k]) for k in self.labelStyle])
return asUnicode("<span style='%s'>%s</span>") % (style, s)
示例6: labelString
def labelString(self):
if self.labelUnits == "":
if self.scale == 1.0:
units = ""
else:
units = asUnicode("(x%g)") % (1.0 / self.scale)
else:
# print repr(self.labelUnitPrefix), repr(self.labelUnits)
units = asUnicode("(%s%s)") % (self.labelUnitPrefix, self.labelUnits)
s = asUnicode("%s %s") % (self.labelText, units)
style = ";".join(["%s: %s" % (k, self.labelStyle[k]) for k in self.labelStyle])
return asUnicode("<span style='%s'>%s</span>") % (style, s)
示例7: headerData
def headerData(self, section, orientation, role=Qt.DisplayRole):
if role == Qt.DisplayRole:
if orientation == Qt.Horizontal:
return self.df.columns[section]
elif orientation == Qt.Vertical:
return asUnicode('{0} | {1}'.format(section, self.df.index.tolist()[section]))
return QtCore.QVariant()
示例8: setViewList
def setViewList(self, views):
names = ['']
self.viewMap.clear()
## generate list of views to show in the link combo
for v in views:
name = v.name
if name is None: ## unnamed views do not show up in the view list (although they are linkable)
continue
names.append(name)
self.viewMap[name] = v
for i in [0,1]:
c = self.ctrl[i].linkCombo
current = asUnicode(c.currentText())
c.blockSignals(True)
changed = True
try:
c.clear()
for name in names:
c.addItem(name)
if name == current:
changed = False
c.setCurrentIndex(c.count()-1)
finally:
c.blockSignals(False)
if changed:
c.setCurrentIndex(0)
c.currentIndexChanged.emit(c.currentIndex())
示例9: setMinimum
def setMinimum(self, m, update=True):
"""Set the minimum allowed value (or None for no limit)"""
if m is not None:
m = D(asUnicode(m))
self.opts['bounds'][0] = m
if update:
self.setValue()
示例10: labelString
def labelString(self):
if self.labelUnits == "":
if not self.autoSIPrefix or self.autoSIPrefixScale == 1.0:
units = ""
else:
units = asUnicode("[x%g]") % (1.0/self.autoSIPrefixScale)
else:
units = asUnicode("[%s%s]") % (asUnicode(self.labelUnitPrefix), asUnicode(self.labelUnits))
s_label = asUnicode("%s %s") % (asUnicode(self.labelText), asUnicode(units))
s_style = ";".join(["%s: %s" % (k, self.labelStyle[k]) for k in self.labelStyle])
return asUnicode("<span style='%s'>%s</span>") % (s_style, asUnicode(s_label))
示例11: execCmd
def execCmd(self):
cmd = asUnicode(self.text())
if len(self.history) == 1 or cmd != self.history[1]:
self.history.insert(1, cmd)
#self.lastCmd = cmd
self.history[0] = ""
self.setHistory(0)
self.sigExecuteCmd.emit(cmd)
示例12: setOpts
def setOpts(self, **opts):
"""
Changes the behavior of the SpinBox. Accepts most of the arguments
allowed in :func:`__init__ <pyqtgraph.SpinBox.__init__>`.
"""
#print opts
for k in opts:
if k == 'bounds':
#print opts[k]
self.setMinimum(opts[k][0], update=False)
self.setMaximum(opts[k][1], update=False)
#for i in [0,1]:
#if opts[k][i] is None:
#self.opts[k][i] = None
#else:
#self.opts[k][i] = D(unicode(opts[k][i]))
elif k in ['step', 'minStep']:
self.opts[k] = D(asUnicode(opts[k]))
elif k == 'value':
pass ## don't set value until bounds have been set
else:
self.opts[k] = opts[k]
if 'value' in opts:
self.setValue(opts['value'])
## If bounds have changed, update value to match
if 'bounds' in opts and 'value' not in opts:
self.setValue()
## sanity checks:
if self.opts['int']:
if 'step' in opts:
step = opts['step']
## not necessary..
#if int(step) != step:
#raise Exception('Integer SpinBox must have integer step size.')
else:
self.opts['step'] = int(self.opts['step'])
if 'minStep' in opts:
step = opts['minStep']
if int(step) != step:
raise Exception('Integer SpinBox must have integer minStep size.')
else:
ms = int(self.opts.get('minStep', 1))
if ms < 1:
ms = 1
self.opts['minStep'] = ms
if 'delay' in opts:
self.proxy.setDelay(opts['delay'])
if 'readonly' in opts:
self.opts['readonly'] = opts['readonly']
self.updateText()
示例13: addChanged
def addChanged(self):
"""Called when "add new" combo is changed
The parameter MUST have an 'addNew' method defined.
"""
if self.addWidget.currentIndex() == 0:
return
typ = asUnicode(self.addWidget.currentText())
self.param.addNew(typ)
self.addWidget.setCurrentIndex(0)
示例14: value
def value(self):
#vals = self.param.opts['limits']
key = asUnicode(self.widget.currentText())
#if isinstance(vals, dict):
#return vals[key]
#else:
#return key
#print key, self.forward
return self.forward.get(key, None)
示例15: validate
def validate(self, strn, pos):
if self.skipValidate:
#print "skip validate"
#self.textValid = False
ret = QtGui.QValidator.Acceptable
else:
try:
## first make sure we didn't mess with the suffix
suff = self.opts.get('suffix', '')
if len(suff) > 0 and asUnicode(strn)[-len(suff):] != suff:
#print '"%s" != "%s"' % (unicode(strn)[-len(suff):], suff)
ret = QtGui.QValidator.Invalid
## next see if we actually have an interpretable value
else:
val = self.interpret()
if val is False:
#print "can't interpret"
#self.setStyleSheet('SpinBox {border: 2px solid #C55;}')
#self.textValid = False
ret = QtGui.QValidator.Intermediate
else:
if self.valueInRange(val):
if not self.opts['delayUntilEditFinished']:
self.setValue(val, update=False)
#print " OK:", self.val
#self.setStyleSheet('')
#self.textValid = True
ret = QtGui.QValidator.Acceptable
else:
ret = QtGui.QValidator.Intermediate
except:
#print " BAD"
#import sys
#sys.excepthook(*sys.exc_info())
#self.textValid = False
#self.setStyleSheet('SpinBox {border: 2px solid #C55;}')
ret = QtGui.QValidator.Intermediate
## draw / clear border
if ret == QtGui.QValidator.Intermediate:
self.textValid = False
elif ret == QtGui.QValidator.Acceptable:
self.textValid = True
## note: if text is invalid, we don't change the textValid flag
## since the text will be forced to its previous state anyway
self.update()
## support 2 different pyqt APIs. Bleh.
if hasattr(QtCore, 'QString'):
return (ret, pos)
else:
return (ret, strn, pos)