本文整理汇总了Python中pyqtgraph.python2_3.asUnicode函数的典型用法代码示例。如果您正苦于以下问题:Python asUnicode函数的具体用法?Python asUnicode怎么用?Python asUnicode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了asUnicode函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()
开发者ID:cdd1969,项目名称:pygwa,代码行数:31,代码来源:PandasQModels.py
示例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)
开发者ID:cycomanic,项目名称:pyqtgraph,代码行数:12,代码来源:parameterTypes.py
示例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'))
开发者ID:cdd1969,项目名称:pygwa,代码行数:14,代码来源:node_readxls.py
示例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)
开发者ID:3rdcycle,项目名称:pyqtgraph,代码行数:14,代码来源:Exporter.py
示例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)
开发者ID:cycomanic,项目名称:pyqtgraph,代码行数:15,代码来源:AxisItem.py
示例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)
开发者ID:fivejjs,项目名称:pyqtgraph,代码行数:15,代码来源:AxisItem.py
示例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()
开发者ID:cdd1969,项目名称:pygwa,代码行数:7,代码来源:PandasQModels.py
示例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())
开发者ID:ZhuangER,项目名称:robot_path_planning,代码行数:30,代码来源:ViewBoxMenu.py
示例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()
开发者ID:3rdcycle,项目名称:pyqtgraph,代码行数:7,代码来源:SpinBox.py
示例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))
开发者ID:tobiashelfenstein,项目名称:wuchshuellenrechner,代码行数:13,代码来源:widget_plot.py
示例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)
开发者ID:3rdcycle,项目名称:pyqtgraph,代码行数:8,代码来源:CmdInput.py
示例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()
开发者ID:a-stark,项目名称:qudi,代码行数:57,代码来源:SpinBox.py
示例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)
开发者ID:cycomanic,项目名称:pyqtgraph,代码行数:9,代码来源:parameterTypes.py
示例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)
开发者ID:cycomanic,项目名称:pyqtgraph,代码行数:10,代码来源:parameterTypes.py
示例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)
开发者ID:3rdcycle,项目名称:pyqtgraph,代码行数:55,代码来源:SpinBox.py
示例16: export
def export(self, fileName=None, toBytes=False, copy=False):
if toBytes is False and copy is False and fileName is None:
self.fileSaveDialog(filter="Scalable Vector Graphics (*.svg)")
return
#self.svg = QtSvg.QSvgGenerator()
#self.svg.setFileName(fileName)
#dpi = QtGui.QDesktopWidget().physicalDpiX()
### not really sure why this works, but it seems to be important:
#self.svg.setSize(QtCore.QSize(self.params['width']*dpi/90., self.params['height']*dpi/90.))
#self.svg.setResolution(dpi)
##self.svg.setViewBox()
#targetRect = QtCore.QRect(0, 0, self.params['width'], self.params['height'])
#sourceRect = self.getSourceRect()
#painter = QtGui.QPainter(self.svg)
#try:
#self.setExportMode(True)
#self.render(painter, QtCore.QRectF(targetRect), sourceRect)
#finally:
#self.setExportMode(False)
#painter.end()
## Workaround to set pen widths correctly
#data = open(fileName).readlines()
#for i in range(len(data)):
#line = data[i]
#m = re.match(r'(<g .*)stroke-width="1"(.*transform="matrix\(([^\)]+)\)".*)', line)
#if m is not None:
##print "Matched group:", line
#g = m.groups()
#matrix = list(map(float, g[2].split(',')))
##print "matrix:", matrix
#scale = max(abs(matrix[0]), abs(matrix[3]))
#if scale == 0 or scale == 1.0:
#continue
#data[i] = g[0] + ' stroke-width="%0.2g" ' % (1.0/scale) + g[1] + '\n'
##print "old line:", line
##print "new line:", data[i]
#open(fileName, 'w').write(''.join(data))
## Qt's SVG generator is not complete. (notably, it lacks clipping)
## Instead, we will use Qt to generate SVG for each item independently,
## then manually reconstruct the entire document.
xml = generateSvg(self.item)
if toBytes:
return xml.encode('UTF-8')
elif copy:
md = QtCore.QMimeData()
md.setData('image/svg+xml', QtCore.QByteArray(xml.encode('UTF-8')))
QtGui.QApplication.clipboard().setMimeData(md)
else:
with open(fileName, 'wb') as fh:
fh.write(asUnicode(xml).encode('utf-8'))
开发者ID:3rdcycle,项目名称:pyqtgraph,代码行数:54,代码来源:SVGExporter.py
示例17: setMinimum
def setMinimum(self, m, update=True):
"""Set the minimum allowed value (or None for no limit)"""
if m is not None:
#FIX: insert the integer functionality:
if self.opts['int']:
m = int(m)
m = D(asUnicode(m))
self.opts['bounds'][0] = m
if update:
self.setValue()
开发者ID:a-stark,项目名称:qudi,代码行数:12,代码来源:SpinBox.py
示例18: serialize
def serialize(self, useSelection=False):
"""Convert entire table (or just selected area) into tab-separated text values"""
if useSelection:
selection = self.selectedRanges()[0]
rows = list(range(selection.topRow(),
selection.bottomRow() + 1))
columns = list(range(selection.leftColumn(),
selection.rightColumn() + 1))
else:
rows = list(range(self.rowCount()))
columns = list(range(self.columnCount()))
data = []
if self.horizontalHeadersSet:
row = []
if self.verticalHeadersSet:
row.append(asUnicode(''))
for c in columns:
row.append(asUnicode(self.horizontalHeaderItem(c).text()))
data.append(row)
for r in rows:
row = []
if self.verticalHeadersSet:
row.append(asUnicode(self.verticalHeaderItem(r).text()))
for c in columns:
item = self.item(r, c)
if item is not None:
row.append(asUnicode(item.value))
else:
row.append(asUnicode(''))
data.append(row)
s = ''
for row in data:
s += ('\t'.join(row) + '\n')
return s
开发者ID:3rdcycle,项目名称:pyqtgraph,代码行数:39,代码来源:TableWidget.py
示例19: mapping
def mapping(limits):
## Return forward and reverse mapping dictionaries given a limit specification
forward = OrderedDict() ## name: value
reverse = OrderedDict() ## value: name
if isinstance(limits, dict):
for k, v in limits.items():
forward[k] = v
reverse[v] = k
else:
for v in limits:
n = asUnicode(v)
forward[n] = v
reverse[v] = n
return forward, reverse
开发者ID:cycomanic,项目名称:pyqtgraph,代码行数:14,代码来源:parameterTypes.py
示例20: selectNumber
def selectNumber(self):
"""
Select the numerical portion of the text to allow quick editing by the user.
"""
le = self.lineEdit()
text = asUnicode(le.text())
if self.opts['suffix'] == '':
le.setSelection(0, len(text))
else:
try:
index = text.index(' ')
except ValueError:
return
le.setSelection(0, index)
开发者ID:a-stark,项目名称:qudi,代码行数:14,代码来源:SpinBox.py
注:本文中的pyqtgraph.python2_3.asUnicode函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论